@@ -2,7 +2,6 @@ import * as http from 'http'
22import * as httpm from '../_out'
33import * as pm from '../_out/proxy'
44import * as proxy from 'proxy'
5- import * as url from 'url'
65
76let _proxyConnects : string [ ]
87let _proxyServer : http . Server
@@ -39,107 +38,107 @@ describe('proxy', () => {
3938 } )
4039
4140 it ( 'getProxyUrl does not return proxyUrl if variables not set' , ( ) => {
42- let proxyUrl = pm . getProxyUrl ( url . parse ( 'https://github.com' ) )
41+ let proxyUrl = pm . getProxyUrl ( new URL ( 'https://github.com' ) )
4342 expect ( proxyUrl ) . toBeUndefined ( )
4443 } )
4544
4645 it ( 'getProxyUrl returns proxyUrl if https_proxy set for https url' , ( ) => {
4746 process . env [ 'https_proxy' ] = 'https://myproxysvr'
48- let proxyUrl = pm . getProxyUrl ( url . parse ( 'https://github.com' ) )
47+ let proxyUrl = pm . getProxyUrl ( new URL ( 'https://github.com' ) )
4948 expect ( proxyUrl ) . toBeDefined ( )
5049 } )
5150
5251 it ( 'getProxyUrl does not return proxyUrl if http_proxy set for https url' , ( ) => {
5352 process . env [ 'http_proxy' ] = 'https://myproxysvr'
54- let proxyUrl = pm . getProxyUrl ( url . parse ( 'https://github.com' ) )
53+ let proxyUrl = pm . getProxyUrl ( new URL ( 'https://github.com' ) )
5554 expect ( proxyUrl ) . toBeUndefined ( )
5655 } )
5756
5857 it ( 'getProxyUrl returns proxyUrl if http_proxy set for http url' , ( ) => {
5958 process . env [ 'http_proxy' ] = 'http://myproxysvr'
60- let proxyUrl = pm . getProxyUrl ( url . parse ( 'http://github.com' ) )
59+ let proxyUrl = pm . getProxyUrl ( new URL ( 'http://github.com' ) )
6160 expect ( proxyUrl ) . toBeDefined ( )
6261 } )
6362
6463 it ( 'getProxyUrl does not return proxyUrl if https_proxy set and in no_proxy list' , ( ) => {
6564 process . env [ 'https_proxy' ] = 'https://myproxysvr'
6665 process . env [ 'no_proxy' ] = 'otherserver,myserver,anotherserver:8080'
67- let proxyUrl = pm . getProxyUrl ( url . parse ( 'https://myserver' ) )
66+ let proxyUrl = pm . getProxyUrl ( new URL ( 'https://myserver' ) )
6867 expect ( proxyUrl ) . toBeUndefined ( )
6968 } )
7069
7170 it ( 'getProxyUrl returns proxyUrl if https_proxy set and not in no_proxy list' , ( ) => {
7271 process . env [ 'https_proxy' ] = 'https://myproxysvr'
7372 process . env [ 'no_proxy' ] = 'otherserver,myserver,anotherserver:8080'
74- let proxyUrl = pm . getProxyUrl ( url . parse ( 'https://github.com' ) )
73+ let proxyUrl = pm . getProxyUrl ( new URL ( 'https://github.com' ) )
7574 expect ( proxyUrl ) . toBeDefined ( )
7675 } )
7776
7877 it ( 'getProxyUrl does not return proxyUrl if http_proxy set and in no_proxy list' , ( ) => {
7978 process . env [ 'http_proxy' ] = 'http://myproxysvr'
8079 process . env [ 'no_proxy' ] = 'otherserver,myserver,anotherserver:8080'
81- let proxyUrl = pm . getProxyUrl ( url . parse ( 'http://myserver' ) )
80+ let proxyUrl = pm . getProxyUrl ( new URL ( 'http://myserver' ) )
8281 expect ( proxyUrl ) . toBeUndefined ( )
8382 } )
8483
8584 it ( 'getProxyUrl returns proxyUrl if http_proxy set and not in no_proxy list' , ( ) => {
8685 process . env [ 'http_proxy' ] = 'http://myproxysvr'
8786 process . env [ 'no_proxy' ] = 'otherserver,myserver,anotherserver:8080'
88- let proxyUrl = pm . getProxyUrl ( url . parse ( 'http://github.com' ) )
87+ let proxyUrl = pm . getProxyUrl ( new URL ( 'http://github.com' ) )
8988 expect ( proxyUrl ) . toBeDefined ( )
9089 } )
9190
9291 it ( 'checkBypass returns true if host as no_proxy list' , ( ) => {
9392 process . env [ 'no_proxy' ] = 'myserver'
94- let bypass = pm . checkBypass ( url . parse ( 'https://myserver' ) )
93+ let bypass = pm . checkBypass ( new URL ( 'https://myserver' ) )
9594 expect ( bypass ) . toBeTruthy ( )
9695 } )
9796
9897 it ( 'checkBypass returns true if host in no_proxy list' , ( ) => {
9998 process . env [ 'no_proxy' ] = 'otherserver,myserver,anotherserver:8080'
100- let bypass = pm . checkBypass ( url . parse ( 'https://myserver' ) )
99+ let bypass = pm . checkBypass ( new URL ( 'https://myserver' ) )
101100 expect ( bypass ) . toBeTruthy ( )
102101 } )
103102
104103 it ( 'checkBypass returns true if host in no_proxy list with spaces' , ( ) => {
105104 process . env [ 'no_proxy' ] = 'otherserver, myserver ,anotherserver:8080'
106- let bypass = pm . checkBypass ( url . parse ( 'https://myserver' ) )
105+ let bypass = pm . checkBypass ( new URL ( 'https://myserver' ) )
107106 expect ( bypass ) . toBeTruthy ( )
108107 } )
109108
110109 it ( 'checkBypass returns true if host in no_proxy list with port' , ( ) => {
111110 process . env [ 'no_proxy' ] = 'otherserver, myserver:8080 ,anotherserver'
112- let bypass = pm . checkBypass ( url . parse ( 'https://myserver:8080' ) )
111+ let bypass = pm . checkBypass ( new URL ( 'https://myserver:8080' ) )
113112 expect ( bypass ) . toBeTruthy ( )
114113 } )
115114
116115 it ( 'checkBypass returns true if host with port in no_proxy list without port' , ( ) => {
117116 process . env [ 'no_proxy' ] = 'otherserver, myserver ,anotherserver'
118- let bypass = pm . checkBypass ( url . parse ( 'https://myserver:8080' ) )
117+ let bypass = pm . checkBypass ( new URL ( 'https://myserver:8080' ) )
119118 expect ( bypass ) . toBeTruthy ( )
120119 } )
121120
122121 it ( 'checkBypass returns true if host in no_proxy list with default https port' , ( ) => {
123122 process . env [ 'no_proxy' ] = 'otherserver, myserver:443 ,anotherserver'
124- let bypass = pm . checkBypass ( url . parse ( 'https://myserver' ) )
123+ let bypass = pm . checkBypass ( new URL ( 'https://myserver' ) )
125124 expect ( bypass ) . toBeTruthy ( )
126125 } )
127126
128127 it ( 'checkBypass returns true if host in no_proxy list with default http port' , ( ) => {
129128 process . env [ 'no_proxy' ] = 'otherserver, myserver:80 ,anotherserver'
130- let bypass = pm . checkBypass ( url . parse ( 'http://myserver' ) )
129+ let bypass = pm . checkBypass ( new URL ( 'http://myserver' ) )
131130 expect ( bypass ) . toBeTruthy ( )
132131 } )
133132
134133 it ( 'checkBypass returns false if host not in no_proxy list' , ( ) => {
135134 process . env [ 'no_proxy' ] = 'otherserver, myserver ,anotherserver:8080'
136- let bypass = pm . checkBypass ( url . parse ( 'https://github.com' ) )
135+ let bypass = pm . checkBypass ( new URL ( 'https://github.com' ) )
137136 expect ( bypass ) . toBeFalsy ( )
138137 } )
139138
140139 it ( 'checkBypass returns false if empty no_proxy' , ( ) => {
141140 process . env [ 'no_proxy' ] = ''
142- let bypass = pm . checkBypass ( url . parse ( 'https://github.com' ) )
141+ let bypass = pm . checkBypass ( new URL ( 'https://github.com' ) )
143142 expect ( bypass ) . toBeFalsy ( )
144143 } )
145144
0 commit comments