@@ -10,7 +10,7 @@ import { runProxiedRequest } from '../common/proxy-server.js';
1010const server = http . createServer ( common . mustCall ( ( req , res ) => {
1111 res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
1212 res . end ( 'Hello World\n' ) ;
13- } , 5 ) ) ;
13+ } , 7 ) ) ;
1414server . on ( 'error' , common . mustNotCall ( ( err ) => { console . error ( 'Server error' , err ) ; } ) ) ;
1515server . listen ( 0 , '127.0.0.1' ) ;
1616await once ( server , 'listening' ) ;
@@ -78,6 +78,44 @@ await once(proxy, 'listening');
7878 assert . strictEqual ( signal , null ) ;
7979}
8080
81+ // Test NO_PROXY ignores a trailing dot in the request hostname.
82+ {
83+ const { code, signal, stderr, stdout } = await runProxiedRequest ( {
84+ NODE_USE_ENV_PROXY : 1 ,
85+ REQUEST_URL : `http://test.example.com.:${ server . address ( ) . port } /test` ,
86+ HTTP_PROXY : `http://localhost:${ proxy . address ( ) . port } ` ,
87+ RESOLVE_TO_LOCALHOST : 'test.example.com.' ,
88+ NO_PROXY : 'test.example.com' ,
89+ } ) ;
90+
91+ // The request should succeed and bypass proxy.
92+ assert . match ( stdout , / S t a t u s C o d e : 2 0 0 / ) ;
93+ assert . match ( stdout , / H e l l o W o r l d / ) ;
94+ assert . match ( stdout , / R e s o l v i n g l o o k u p f o r t e s t \. e x a m p l e \. c o m \. / ) ;
95+ assert . strictEqual ( stderr . trim ( ) , '' ) ;
96+ assert . strictEqual ( code , 0 ) ;
97+ assert . strictEqual ( signal , null ) ;
98+ }
99+
100+ // Test NO_PROXY ignores a trailing dot in the entry.
101+ {
102+ const { code, signal, stderr, stdout } = await runProxiedRequest ( {
103+ NODE_USE_ENV_PROXY : 1 ,
104+ REQUEST_URL : `http://test.example.com:${ server . address ( ) . port } /test` ,
105+ HTTP_PROXY : `http://localhost:${ proxy . address ( ) . port } ` ,
106+ RESOLVE_TO_LOCALHOST : 'test.example.com' ,
107+ NO_PROXY : 'test.example.com.' ,
108+ } ) ;
109+
110+ // The request should succeed and bypass proxy.
111+ assert . match ( stdout , / S t a t u s C o d e : 2 0 0 / ) ;
112+ assert . match ( stdout , / H e l l o W o r l d / ) ;
113+ assert . match ( stdout , / R e s o l v i n g l o o k u p f o r t e s t \. e x a m p l e \. c o m / ) ;
114+ assert . strictEqual ( stderr . trim ( ) , '' ) ;
115+ assert . strictEqual ( code , 0 ) ;
116+ assert . strictEqual ( signal , null ) ;
117+ }
118+
81119// Test NO_PROXY with leading-dot entry should NOT match partial domain names.
82120// Regression test: .example.com must not match notexample.com or badexample.com.
83121{
0 commit comments