@microlink/cli 2.1.58 → 2.1.59

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 +16 -11
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.58",
5
+ "version": "2.1.59",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
8
  "microlink": "bin/microlink",
package/src/api.js CHANGED
@@ -48,17 +48,22 @@ const normalizeInput = (input, endpoint) => {
48
48
  // query string) so a bare target URL is left untouched.
49
49
  let isApiInput = /^\??url=/.test(input) || input.startsWith('?')
50
50
 
51
- // Always strip a canonical `*.microlink.io` host (users paste these into any
52
- // binary), plus the binary's own endpoint host when it isn't on microlink.io.
53
- const sanitizers = [microlinkUrl()]
54
- const endpointRegex = endpointUrl(endpoint)
55
- if (endpointRegex) sanitizers.push(endpointRegex)
56
-
57
- for (const regex of sanitizers) {
58
- const next = normalized.replace(regex, '')
59
- if (next !== normalized) {
60
- isApiInput = true
61
- normalized = next
51
+ // Host stripping only applies to an actual API request, which always carries a
52
+ // `url=` query. A bare target URL even on a microlink.io content host such as
53
+ // cdn.microlink.io has none, so its host must survive untouched.
54
+ if (/(?:^|[?&])url=/.test(input)) {
55
+ // Strip a canonical `*.microlink.io` host (users paste these into any
56
+ // binary), plus the binary's own endpoint host when it isn't on microlink.io.
57
+ const sanitizers = [microlinkUrl()]
58
+ const endpointRegex = endpointUrl(endpoint)
59
+ if (endpointRegex) sanitizers.push(endpointRegex)
60
+
61
+ for (const regex of sanitizers) {
62
+ const next = normalized.replace(regex, '')
63
+ if (next !== normalized) {
64
+ isApiInput = true
65
+ normalized = next
66
+ }
62
67
  }
63
68
  }
64
69