@@ -36,7 +36,7 @@ interface HttpTransportOptions extends BaseTransportOptions {
36
36
*/
37
37
export function makeNewHttpTransport ( options : HttpTransportOptions ) : NewTransport {
38
38
// Proxy prioritization: http => `options.proxy` | `process.env.http_proxy`
39
- const proxy = filterNoProxy ( options . url , options . proxy || process . env . http_proxy ) ;
39
+ const proxy = applyNoProxyOption ( options . url , options . proxy || process . env . http_proxy ) ;
40
40
41
41
const httpModule = options . httpModule ?? http ;
42
42
@@ -53,7 +53,7 @@ export function makeNewHttpTransport(options: HttpTransportOptions): NewTranspor
53
53
*/
54
54
export function makeNewHttpsTransport ( options : HttpTransportOptions ) : NewTransport {
55
55
// Proxy prioritization: https => `options.proxy` | `process.env.https_proxy` | `process.env.http_proxy`
56
- const proxy = filterNoProxy ( options . url , options . proxy || process . env . https_proxy || process . env . http_proxy ) ;
56
+ const proxy = applyNoProxyOption ( options . url , options . proxy || process . env . https_proxy || process . env . http_proxy ) ;
57
57
58
58
const httpsModule = options . httpModule ?? https ;
59
59
@@ -72,10 +72,16 @@ export function makeNewHttpsTransport(options: HttpTransportOptions): NewTranspo
72
72
* @param proxy The client configured proxy.
73
73
* @returns A proxy the transport should use.
74
74
*/
75
- function filterNoProxy ( transportUrl : string , proxy : string | undefined ) : string | undefined {
75
+ function applyNoProxyOption ( transportUrl : string , proxy : string | undefined ) : string | undefined {
76
76
const { no_proxy } = process . env ;
77
77
78
- const urlIsExemptFromProxy = no_proxy && no_proxy . split ( ',' ) . some ( exemption => transportUrl . endsWith ( exemption ) ) ;
78
+ const { host : transportUrlHost , hostname : transportUrlHostname } = new URL ( transportUrl ) ;
79
+
80
+ const urlIsExemptFromProxy =
81
+ no_proxy &&
82
+ no_proxy
83
+ . split ( ',' )
84
+ . some ( exemption => transportUrlHost . endsWith ( exemption ) || transportUrlHostname . endsWith ( exemption ) ) ;
79
85
80
86
if ( urlIsExemptFromProxy ) {
81
87
return undefined ;
0 commit comments