Prepend http:// to http(s)_proxy env if missing (#1439)

* Prepend http:// to http(s)_proxy env if missing

* Formatting

* Fix linting
This commit is contained in:
Ferenc Hammerl authored and GitHub committed 2023-06-22 11:03:38 +02:00
1 parent 9d8bfe0007
commit 081fb7ff98
2 files changed
+12 -1

No files matched your search

+6 -1
View File
@@ -14,7 +14,12 @@ export function getProxyUrl(reqUrl: URL): URL | undefined {
})()
if (proxyVar) {
return new URL(proxyVar)
try {
return new URL(proxyVar)
} catch {
if (!proxyVar.startsWith('http://') && !proxyVar.startsWith('https://'))
return new URL(`http://${proxyVar}`)
}
} else {
return undefined
}