@@ -34,6 +34,12 @@ interface ManifestLookupOptions {
34
34
35
35
const FingerprintedExtensions = new Set ( [ '.css' , '.js' , '.svg' ] ) ;
36
36
37
+ function preserveQueryString ( req : express . Request , destination : string ) {
38
+ return req . originalUrl . includes ( '?' )
39
+ ? `${ destination } ?${ req . originalUrl . split ( '?' ) [ 1 ] } `
40
+ : destination ;
41
+ }
42
+
37
43
export const getManifest = async ( siteId : string , branchOrRef : string ) => {
38
44
const keys = [
39
45
datastore . key ( [ 'Fileset2Manifest' , `${ siteId } :branch:${ branchOrRef } ` ] ) ,
@@ -304,9 +310,7 @@ export function createApp(siteId: string) {
304
310
const result = route . getRedirect ( params ) ;
305
311
const code = result [ 0 ] ;
306
312
let destination = result [ 1 ] ;
307
- destination = req . originalUrl . includes ( '?' )
308
- ? `${ destination } ?${ req . originalUrl . split ( '?' ) [ 1 ] } `
309
- : destination ;
313
+ destination = preserveQueryString ( req , destination ) ;
310
314
res . redirect ( code , destination ) ;
311
315
return ;
312
316
}
@@ -363,7 +367,7 @@ export function createApp(siteId: string) {
363
367
( manifestPaths [ `${ urlPath } /index.html` ] ||
364
368
manifestPaths [ `${ urlPath . toLowerCase ( ) } /index.html` ] )
365
369
) {
366
- const destination = ` ${ urlPath } /` ;
370
+ const destination = preserveQueryString ( req , urlPath ) ;
367
371
res . redirect ( 301 , destination ) ;
368
372
return ;
369
373
}
0 commit comments