@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.
- package/package.json +1 -1
- package/src/api.js +16 -11
package/package.json
CHANGED
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
|
-
//
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
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
|
|