@@ -182,30 +182,28 @@ describe("lib/http-proxy/common.js", () => {
182182
183183 it ( "should keep the original target path in the outgoing path" , ( ) => {
184184 const outgoing = { } as any ;
185- common . setupOutgoing ( outgoing , { target : { path : " some-path" } } , {
185+ common . setupOutgoing ( outgoing , { target : URL . parse ( "http://localhost/ some-path") ! } , {
186186 url : "am" ,
187187 } as any ) ;
188188
189- expect ( outgoing . path ) . to . eql ( "some-path/am" ) ;
189+ expect ( outgoing . path ) . to . eql ( "/ some-path/am" ) ;
190190 } ) ;
191191
192192 it ( "should keep the original forward path in the outgoing path" , ( ) => {
193193 const outgoing = { } as any ;
194194 common . setupOutgoing (
195195 outgoing ,
196196 {
197- target : { } ,
198- forward : {
199- path : "some-path" ,
200- } ,
197+ target : "http://localhost" ,
198+ forward : URL . parse ( "http://localhost/some-path" ) ! ,
201199 } ,
202200 {
203201 url : "am" ,
204202 } as any ,
205203 "forward" ,
206204 ) ;
207205
208- expect ( outgoing . path ) . to . eql ( "some-path/am" ) ;
206+ expect ( outgoing . path ) . to . eql ( "/ some-path/am" ) ;
209207 } ) ;
210208
211209 it ( "should properly detect https/wss protocol without the colon" , ( ) => {
@@ -229,7 +227,7 @@ describe("lib/http-proxy/common.js", () => {
229227 common . setupOutgoing (
230228 outgoing ,
231229 {
232- target : { path : " hellothere" } ,
230+ target : URL . parse ( "http://localhost/ hellothere") ! ,
233231 prependPath : false ,
234232 } ,
235233 { url : "hi" } as any ,
@@ -243,7 +241,7 @@ describe("lib/http-proxy/common.js", () => {
243241 common . setupOutgoing (
244242 outgoing ,
245243 {
246- target : { path : "/ forward" } ,
244+ target : URL . parse ( "http://localhost/ forward") ! ,
247245 } ,
248246 { url : "/static/path" } as any ,
249247 ) ;
@@ -270,7 +268,7 @@ describe("lib/http-proxy/common.js", () => {
270268 common . setupOutgoing (
271269 outgoing ,
272270 {
273- target : { path : "/ forward" } ,
271+ target : URL . parse ( "http://localhost/ forward") ! ,
274272 } ,
275273 {
276274 url : "/?foo=bar//&target=http://foobar.com/?a=1%26b=2&other=2" ,
@@ -364,7 +362,7 @@ describe("lib/http-proxy/common.js", () => {
364362 } ) ;
365363
366364 describe ( "when using changeOrigin" , ( ) => {
367- it ( "should correctly set the port to the host when it is a non-standard port using url .parse" , ( ) => {
365+ it ( "should correctly set the port to the host when it is a non-standard port using URL .parse" , ( ) => {
368366 const outgoing = { } as any ;
369367 const myEndpoint = "https://myCouch.com:6984" ;
370368 common . setupOutgoing (
@@ -459,14 +457,13 @@ describe("lib/http-proxy/common.js", () => {
459457 expect ( outgoing . method ) . eql ( "POST" ) ;
460458 } ) ;
461459
462- // url.parse('').path => null
463- it ( "should not pass null as last arg to #urlJoin" , ( ) => {
460+ it ( "should handle empty pathname target" , ( ) => {
464461 const outgoing = { } as any ;
465- common . setupOutgoing ( outgoing , { target : { path : "" } } , {
462+ common . setupOutgoing ( outgoing , { target : URL . parse ( "http://localhost" ) ! } , {
466463 url : "" ,
467464 } as any ) ;
468465
469- expect ( outgoing . path ) . toBe ( "/" ) ; // leading slash is new in httpxy
466+ expect ( outgoing . path ) . toBe ( "/" ) ;
470467 } ) ;
471468 } ) ;
472469
0 commit comments