(env, archive, version)
| 61 | // Non-https / malformed npm_config_registry is silently ignored so npm users |
| 62 | // with http-only internal registries don't have their installs broken. |
| 63 | function resolveMirrorUrls(env, archive, version) { |
| 64 | const binaryPath = `/-/binary/lark-cli/v${version}/${archive}`; |
| 65 | const defaultUrl = joinUrl(DEFAULT_MIRROR_HOST, binaryPath); |
| 66 | |
| 67 | const urls = []; |
| 68 | const registry = (env.npm_config_registry || "").trim(); |
| 69 | if (registry && !isDefaultNpmjsRegistry(registry) && isValidDownloadBase(registry)) { |
| 70 | const base = new URL(registry); |
| 71 | urls.push(joinUrl(base.origin + base.pathname, binaryPath)); |
| 72 | } |
| 73 | if (!urls.includes(defaultUrl)) urls.push(defaultUrl); |
| 74 | return urls; |
| 75 | } |
| 76 | |
| 77 | function joinUrl(base, suffix) { |
| 78 | return base.replace(/\/+$/, "") + suffix; |
no test coverage detected