@@ -321,7 +321,7 @@ describe("withNoProxyForLocalhost preserves user-configured NO_PROXY", () => {
321321
322322 await withNoProxyForLocalhost ( async ( ) => {
323323 expect ( process . env . NO_PROXY ) . toBe ( `${ coveredNoProxy } ,localhost,127.0.0.1,[::1]` ) ;
324- expect ( process . env . no_proxy ) . toBe ( `${ coveredNoProxy } ,localhost,127.0.0.1,[::1]` ) ;
324+ expect ( process . env . no_proxy ) . toBe ( `${ staleLowerNoProxy } ,localhost,127.0.0.1,[::1]` ) ;
325325 } ) ;
326326
327327 expect ( process . env . NO_PROXY ) . toBe ( coveredNoProxy ) ;
@@ -333,6 +333,53 @@ describe("withNoProxyForLocalhost preserves user-configured NO_PROXY", () => {
333333 }
334334 } ) ;
335335
336+ it ( "mirrors lowercase-only bypass entries into uppercase during the lease" , async ( ) => {
337+ const lowerNoProxy = "corp.internal" ;
338+ delete process . env . NO_PROXY ;
339+ process . env . no_proxy = lowerNoProxy ;
340+ process . env . HTTP_PROXY = "http://proxy:8080" ;
341+
342+ try {
343+ const { withNoProxyForLocalhost } = await import ( "./cdp-proxy-bypass.js" ) ;
344+
345+ await withNoProxyForLocalhost ( async ( ) => {
346+ expect ( process . env . NO_PROXY ) . toBe ( `${ lowerNoProxy } ,localhost,127.0.0.1,[::1]` ) ;
347+ expect ( process . env . no_proxy ) . toBe ( `${ lowerNoProxy } ,localhost,127.0.0.1,[::1]` ) ;
348+ } ) ;
349+
350+ expect ( process . env . NO_PROXY ) . toBeUndefined ( ) ;
351+ expect ( process . env . no_proxy ) . toBe ( lowerNoProxy ) ;
352+ } finally {
353+ delete process . env . HTTP_PROXY ;
354+ delete process . env . NO_PROXY ;
355+ delete process . env . no_proxy ;
356+ }
357+ } ) ;
358+
359+ it ( "restores untouched NO_PROXY casing when the lowercase value changes" , async ( ) => {
360+ const userNoProxy = "internal.corp" ;
361+ process . env . NO_PROXY = userNoProxy ;
362+ process . env . no_proxy = userNoProxy ;
363+ process . env . HTTP_PROXY = "http://proxy:8080" ;
364+
365+ try {
366+ const { withNoProxyForLocalhost } = await import ( "./cdp-proxy-bypass.js" ) ;
367+
368+ await withNoProxyForLocalhost ( async ( ) => {
369+ expect ( process . env . NO_PROXY ) . toBe ( `${ userNoProxy } ,localhost,127.0.0.1,[::1]` ) ;
370+ expect ( process . env . no_proxy ) . toBe ( `${ userNoProxy } ,localhost,127.0.0.1,[::1]` ) ;
371+ delete process . env . no_proxy ;
372+ } ) ;
373+
374+ expect ( process . env . NO_PROXY ) . toBe ( userNoProxy ) ;
375+ expect ( process . env . no_proxy ) . toBeUndefined ( ) ;
376+ } finally {
377+ delete process . env . HTTP_PROXY ;
378+ delete process . env . NO_PROXY ;
379+ delete process . env . no_proxy ;
380+ }
381+ } ) ;
382+
336383 it ( "does not treat substring matches as complete loopback coverage" , async ( ) => {
337384 const userNoProxy = "notlocalhost,127.0.0.10,[::1].example" ;
338385 process . env . NO_PROXY = userNoProxy ;
@@ -392,7 +439,7 @@ describe("withNoProxyForCdpUrl", () => {
392439 }
393440 } ) ;
394441
395- it ( "does not restore stale no_proxy when it was deleted during execution" , async ( ) => {
442+ it ( "restores untouched NO_PROXY when no_proxy was deleted during execution" , async ( ) => {
396443 process . env . HTTP_PROXY = "http://proxy:8080" ;
397444 process . env . NO_PROXY = "corp.internal" ;
398445 process . env . no_proxy = "corp.internal" ;
@@ -402,7 +449,7 @@ describe("withNoProxyForCdpUrl", () => {
402449 expect ( process . env . no_proxy ) . toBe ( "corp.internal,localhost,127.0.0.1,[::1]" ) ;
403450 delete process . env . no_proxy ;
404451 } ) ;
405- expect ( process . env . NO_PROXY ) . toBe ( "corp.internal,localhost,127.0.0.1,[::1] " ) ;
452+ expect ( process . env . NO_PROXY ) . toBe ( "corp.internal" ) ;
406453 expect ( process . env . no_proxy ) . toBeUndefined ( ) ;
407454 } finally {
408455 delete process . env . HTTP_PROXY ;
0 commit comments