| 82 | // Plain HTTP is accepted only for an exact loopback authority, as in |
| 83 | // install.sh; such a fetch uses no proxy and follows no redirect. |
| 84 | function validateLoopbackUrl(rawUrl) { |
| 85 | let parsed = null; |
| 86 | try { |
| 87 | parsed = new URL(rawUrl); |
| 88 | } catch (_) { |
| 89 | // Refused below. |
| 90 | } |
| 91 | if (!LOOPBACK_HTTP_URL.test(rawUrl) || !parsed || parsed.protocol !== 'http:' || |
| 92 | !LOOPBACK_HOSTNAMES.has(parsed.hostname) || parsed.username || parsed.password) { |
| 93 | throw new Error(`Refusing non-loopback HTTP URL: ${rawUrl}`); |
| 94 | } |
| 95 | return parsed.href; |
| 96 | } |
| 97 | |
| 98 | // CBM_DOWNLOAD_URL replaces the release download base (for testing), with |
| 99 | // install.sh's policy: HTTPS, or plain HTTP to an exact loopback authority. |