File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ export function setupOutgoing(
112112
113113 // target if defined is a URL object so has attribute "pathname", not "path".
114114 const targetPath =
115- target && options . prependPath !== false && 'pathname' in target ? getPath ( target . pathname ) : "/" ;
115+ target && options . prependPath !== false && 'pathname' in target ? getPath ( ` ${ target . pathname } ${ target . search ?? "" } ` ) : "/" ;
116116
117117 let outgoingPath = options . toProxy ? req . url : getPath ( req . url ) ;
118118
Original file line number Diff line number Diff line change @@ -292,6 +292,33 @@ describe("#setupOutgoing", () => {
292292 expect ( outgoing . path ) . toEqual ( "/forward/src?f=1&s=1" ) ;
293293 } ) ;
294294
295+ it ( "target path is URL and has query string" , ( ) => {
296+ const outgoing : any = { } ;
297+ setupOutgoing (
298+ outgoing ,
299+ {
300+ target : new URL ( "http://dummy.org/some-path?a=1&b=2" ) ,
301+ } ,
302+ { url : "/src?s=1" } ,
303+ ) ;
304+
305+ expect ( outgoing . path ) . toEqual ( "/some-path/src?a=1&b=2&s=1" ) ;
306+ } ) ;
307+
308+ it ( "target path is URL and has query string with ignorePath" , ( ) => {
309+ const outgoing : any = { } ;
310+ setupOutgoing (
311+ outgoing ,
312+ {
313+ target : new URL ( "http://dummy.org/some-path?a=1&b=2" ) ,
314+ ignorePath : true ,
315+ } ,
316+ { url : "/src?s=1" } ,
317+ ) ;
318+
319+ expect ( outgoing . path ) . toEqual ( "/some-path?a=1&b=2" ) ;
320+ } ) ;
321+
295322 //
296323 // This is the proper failing test case for the common.join problem
297324 //
You can’t perform that action at this time.
0 commit comments