File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,12 @@ describe('proxy', () => {
91
91
expect ( proxyUrl ) . toBeDefined ( )
92
92
} )
93
93
94
+ it ( 'getProxyUrl returns proxyUrl if http_proxy has no protocol' , ( ) => {
95
+ process . env [ 'http_proxy' ] = 'myproxysvr'
96
+ const proxyUrl = pm . getProxyUrl ( new URL ( 'http://github.com' ) )
97
+ expect ( proxyUrl ?. toString ( ) ) . toBe ( 'http://myproxysvr/' )
98
+ } )
99
+
94
100
it ( 'checkBypass returns true if host as no_proxy list' , ( ) => {
95
101
process . env [ 'no_proxy' ] = 'myserver'
96
102
const bypass = pm . checkBypass ( new URL ( 'https://myserver' ) )
Original file line number Diff line number Diff line change @@ -14,7 +14,12 @@ export function getProxyUrl(reqUrl: URL): URL | undefined {
14
14
} ) ( )
15
15
16
16
if ( proxyVar ) {
17
- return new URL ( proxyVar )
17
+ try {
18
+ return new URL ( proxyVar )
19
+ } catch {
20
+ if ( ! proxyVar . startsWith ( 'http://' ) && ! proxyVar . startsWith ( 'https://' ) )
21
+ return new URL ( `http://${ proxyVar } ` )
22
+ }
18
23
} else {
19
24
return undefined
20
25
}
You can’t perform that action at this time.
0 commit comments