@microlink/cli 2.1.34 → 2.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/api.js +4 -4
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@microlink/cli",
3
3
  "description": "Interacting with Microlink API from your terminal.",
4
4
  "homepage": "https://github.com/microlinkhq/cli",
5
- "version": "2.1.34",
5
+ "version": "2.1.35",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
8
  "microlink": "bin/microlink",
package/src/api.js CHANGED
@@ -61,14 +61,14 @@ const render = ({ response, flags }) => {
61
61
  const { headers, timings, requestUrl: uri, body } = response
62
62
  if (!flags.pretty) return console.log(body.toString())
63
63
 
64
- const contentType = headers['content-type'].toLowerCase()
64
+ const contentType = headers['content-type'].split(';')[0].toLowerCase()
65
65
  const time = prettyMs(timings.phases.total)
66
66
  const serverTiming = headers['server-timing']
67
67
  const id = headers['x-request-id']
68
68
 
69
69
  const printMode = (() => {
70
70
  if (body.toString().startsWith('data:')) return 'base64'
71
- if (!contentType.includes('utf')) return 'image'
71
+ if (contentType !== 'application/json') return 'image'
72
72
  })()
73
73
 
74
74
  switch (printMode) {
@@ -84,8 +84,8 @@ const render = ({ response, flags }) => {
84
84
  console.log()
85
85
  break
86
86
  default: {
87
- const isText = contentType.includes('text/plain')
88
- const isHtml = contentType.includes('text/html')
87
+ const isText = contentType === 'text/plain'
88
+ const isHtml = contentType === 'text/html'
89
89
  const output = isText || isHtml ? body.toString() : JSON.parse(body)
90
90
  print.json(output, flags)
91
91
  break