@@ -905,17 +905,38 @@ describe("normalizeLocationHeader", () => {
905905
906906 it ( "should normalize and encode special characters in location header" , ( ) => {
907907 const result = normalizeLocationHeader (
908- "http://localhost:3000/æøå ?query=æøå!&" ,
908+ "http://localhost:3000/about ?query=æøå!&" ,
909909 "http://localhost:3000" ,
910+ true ,
910911 ) ;
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! " ) ;
912913 } ) ;
913914
914- it ( "should normalize and respect already encoded characthers in location header" , ( ) => {
915+ it ( "should normalize and respect already encoded characters in location header" , ( ) => {
915916 const result = normalizeLocationHeader (
916917 "http://localhost:3000/path?query=test%2F%2F" ,
917918 "http://localhost:3000" ,
919+ true ,
918920 ) ;
919921 expect ( result ) . toBe ( "/path?query=test%2F%2F" ) ;
920922 } ) ;
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+ } ) ;
921942} ) ;
0 commit comments