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(
112
112
113
113
// target if defined is a URL object so has attribute "pathname", not "path".
114
114
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 ?? "" } ` ) : "/" ;
116
116
117
117
let outgoingPath = options . toProxy ? req . url : getPath ( req . url ) ;
118
118
Original file line number Diff line number Diff line change @@ -292,6 +292,33 @@ describe("#setupOutgoing", () => {
292
292
expect ( outgoing . path ) . toEqual ( "/forward/src?f=1&s=1" ) ;
293
293
} ) ;
294
294
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
+
295
322
//
296
323
// This is the proper failing test case for the common.join problem
297
324
//
You can’t perform that action at this time.
0 commit comments