Compare commits
3 Commits
main
...
fhammerl/p
| Author | SHA1 | Date |
|---|---|---|
|
|
2539b9b685 | |
|
|
60f4e9859c | |
|
|
17e0aec811 |
|
|
@ -91,6 +91,12 @@ describe('proxy', () => {
|
||||||
expect(proxyUrl).toBeDefined()
|
expect(proxyUrl).toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('getProxyUrl returns proxyUrl if http_proxy has no protocol', () => {
|
||||||
|
process.env['http_proxy'] = 'myproxysvr'
|
||||||
|
const proxyUrl = pm.getProxyUrl(new URL('http://github.com'))
|
||||||
|
expect(proxyUrl?.toString()).toBe('http://myproxysvr/')
|
||||||
|
})
|
||||||
|
|
||||||
it('checkBypass returns true if host as no_proxy list', () => {
|
it('checkBypass returns true if host as no_proxy list', () => {
|
||||||
process.env['no_proxy'] = 'myserver'
|
process.env['no_proxy'] = 'myserver'
|
||||||
const bypass = pm.checkBypass(new URL('https://myserver'))
|
const bypass = pm.checkBypass(new URL('https://myserver'))
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,12 @@ export function getProxyUrl(reqUrl: URL): URL | undefined {
|
||||||
})()
|
})()
|
||||||
|
|
||||||
if (proxyVar) {
|
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 {
|
} else {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue