@@ -72,4 +72,36 @@ test.describe("Next Config Redirect", () => {
72
72
} ) ;
73
73
await expect ( el ) . toBeVisible ( ) ;
74
74
} ) ;
75
+ test ( "Should properly encode the Location header for redirects with query params" , async ( { page } ) => {
76
+ await page . goto ( "/config-redirect" ) ;
77
+ const responsePromise = page . waitForResponse ( ( response ) => {
78
+ return response . status ( ) === 307 ;
79
+ } ) ;
80
+ page . getByTestId ( "redirect-link" ) . click ( ) ;
81
+ const res = await responsePromise ;
82
+ await page . waitForURL ( "/config-redirect/dest?q=äöå€" ) ;
83
+
84
+ const locationHeader = res . headers ( ) . location ;
85
+ expect ( locationHeader ) . toBe ( "/config-redirect/dest?q=%C3%A4%C3%B6%C3%A5%E2%82%AC" ) ;
86
+ expect ( res . status ( ) ) . toBe ( 307 ) ;
87
+
88
+ const searchParams = page . getByTestId ( "searchParams" ) ;
89
+ await expect ( searchParams ) . toHaveText ( "q: äöå€" ) ;
90
+ } ) ;
91
+ test ( "Should respect already encoded query params" , async ( { page } ) => {
92
+ await page . goto ( "/config-redirect" ) ;
93
+ const responsePromise = page . waitForResponse ( ( response ) => {
94
+ return response . status ( ) === 307 ;
95
+ } ) ;
96
+ page . getByTestId ( "redirect-link-already-encoded" ) . click ( ) ;
97
+ const res = await responsePromise ;
98
+ await page . waitForURL ( "/config-redirect/dest?q=äöå€" ) ;
99
+
100
+ const locationHeader = res . headers ( ) . location ;
101
+ expect ( locationHeader ) . toBe ( "/config-redirect/dest?q=%C3%A4%C3%B6%C3%A5%E2%82%AC" ) ;
102
+ expect ( res . status ( ) ) . toBe ( 307 ) ;
103
+
104
+ const searchParams = page . getByTestId ( "searchParams" ) ;
105
+ await expect ( searchParams ) . toHaveText ( "q: äöå€" ) ;
106
+ } ) ;
75
107
} ) ;
0 commit comments