@@ -201,7 +201,7 @@ describe("createHttpAgent", () => {
201201 it ( "uses http.noProxy as fallback when coder.proxyBypass is not set" , async ( ) => {
202202 const cfg = new MockConfigurationProvider ( ) ;
203203 cfg . set ( "http.proxy" , proxy ) ;
204- cfg . set ( "http.noProxy" , "internal.example.com" ) ;
204+ cfg . set ( "http.noProxy" , [ "internal.example.com" ] ) ;
205205
206206 const agent = await createHttpAgent ( cfg ) ;
207207
@@ -214,7 +214,7 @@ describe("createHttpAgent", () => {
214214 const cfg = new MockConfigurationProvider ( ) ;
215215 cfg . set ( "http.proxy" , proxy ) ;
216216 cfg . set ( "coder.proxyBypass" , "primary.example.com" ) ;
217- cfg . set ( "http.noProxy" , "fallback.example.com" ) ;
217+ cfg . set ( "http.noProxy" , [ "fallback.example.com" ] ) ;
218218
219219 const agent = await createHttpAgent ( cfg ) ;
220220
@@ -225,5 +225,42 @@ describe("createHttpAgent", () => {
225225 await agent . getProxyForUrl ( "https://fallback.example.com" , mockRequest ) ,
226226 ) . toBe ( proxy ) ;
227227 } ) ;
228+
229+ it ( "trims and joins multiple http.noProxy entries" , async ( ) => {
230+ const cfg = new MockConfigurationProvider ( ) ;
231+ cfg . set ( "http.proxy" , proxy ) ;
232+ cfg . set ( "http.noProxy" , [ " first.example.com " , "second.example.com " ] ) ;
233+
234+ const agent = await createHttpAgent ( cfg ) ;
235+
236+ expect (
237+ await agent . getProxyForUrl ( "https://first.example.com" , mockRequest ) ,
238+ ) . toBe ( "" ) ;
239+ expect (
240+ await agent . getProxyForUrl ( "https://second.example.com" , mockRequest ) ,
241+ ) . toBe ( "" ) ;
242+ expect (
243+ await agent . getProxyForUrl ( "https://other.example.com" , mockRequest ) ,
244+ ) . toBe ( proxy ) ;
245+ } ) ;
246+
247+ interface NoProxyTestCase {
248+ name : string ;
249+ noProxy : string [ ] | undefined ;
250+ }
251+ it . each < NoProxyTestCase > ( [
252+ { name : "undefined" , noProxy : undefined } ,
253+ { name : "empty array" , noProxy : [ ] } ,
254+ ] ) ( "uses proxy when http.noProxy is $name" , async ( { noProxy } ) => {
255+ const cfg = new MockConfigurationProvider ( ) ;
256+ cfg . set ( "http.proxy" , proxy ) ;
257+ cfg . set ( "http.noProxy" , noProxy ) ;
258+
259+ const agent = await createHttpAgent ( cfg ) ;
260+
261+ expect (
262+ await agent . getProxyForUrl ( "https://example.com" , mockRequest ) ,
263+ ) . toBe ( proxy ) ;
264+ } ) ;
228265 } ) ;
229266} ) ;
0 commit comments