@@ -905,17 +905,38 @@ describe("normalizeLocationHeader", () => {
905
905
906
906
it ( "should normalize and encode special characters in location header" , ( ) => {
907
907
const result = normalizeLocationHeader (
908
- "http://localhost:3000/æøå ?query=æøå!&" ,
908
+ "http://localhost:3000/about ?query=æøå!&" ,
909
909
"http://localhost:3000" ,
910
+ true ,
910
911
) ;
911
- expect ( result ) . toBe ( "/%C3%A6%C3%B8%C3%A5 ?query=%C3%A6%C3%B8%C3%A5%21 " ) ;
912
+ expect ( result ) . toBe ( "/about ?query=%C3%A6%C3%B8%C3%A5! " ) ;
912
913
} ) ;
913
914
914
- it ( "should normalize and respect already encoded characthers in location header" , ( ) => {
915
+ it ( "should normalize and respect already encoded characters in location header" , ( ) => {
915
916
const result = normalizeLocationHeader (
916
917
"http://localhost:3000/path?query=test%2F%2F" ,
917
918
"http://localhost:3000" ,
919
+ true ,
918
920
) ;
919
921
expect ( result ) . toBe ( "/path?query=test%2F%2F" ) ;
920
922
} ) ;
923
+
924
+ it ( "should preserve multiple query parameters in location header" , ( ) => {
925
+ const result = normalizeLocationHeader (
926
+ "http://localhost:3000/path?query1=value1&query2=value2&query1=value3&query2=value4&random=randomvalue" ,
927
+ "http://localhost:3000" ,
928
+ true ,
929
+ ) ;
930
+ expect ( result ) . toBe (
931
+ "/path?query1=value1&query1=value3&query2=value2&query2=value4&random=randomvalue" ,
932
+ ) ;
933
+ } ) ;
934
+
935
+ it ( "should return absolute URL correctly when the base URL is different" , ( ) => {
936
+ const result = normalizeLocationHeader (
937
+ "https://example.com/path?query=1" ,
938
+ "http://localhost:3000" ,
939
+ ) ;
940
+ expect ( result ) . toBe ( "https://example.com/path?query=1" ) ;
941
+ } ) ;
921
942
} ) ;
0 commit comments