File tree 3 files changed +22
-1
lines changed
development-runtime/cypress/integration
production-runtime/cypress/integration
packages/gatsby/src/utils/page-ssr-module
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ describe(`Static path ('${staticPath}')`, () => {
35
35
cy . getTestElement ( `query` ) . contains ( `{}` )
36
36
cy . getTestElement ( `params` ) . contains ( `{}` )
37
37
} )
38
+
39
+ it ( `Preserves window.location.search as querystring passed` , ( ) => {
40
+ const queryString = `?a=b%23&x=y%25&j=`
41
+ cy . visit ( staticPath + queryString ) . waitForRouteChange ( )
42
+ cy . window ( ) . then ( win => {
43
+ expect ( win . location . search ) . to . equal ( queryString )
44
+ } )
45
+ } )
38
46
} )
39
47
40
48
describe ( `Param path ('${ paramPath } :param')` , ( ) => {
Original file line number Diff line number Diff line change @@ -36,6 +36,14 @@ describe(`Static path ('${staticPath}')`, () => {
36
36
cy . getTestElement ( `query` ) . contains ( `{}` )
37
37
cy . getTestElement ( `params` ) . contains ( `{}` )
38
38
} )
39
+
40
+ it ( "Preserves window.location.search as querystring passed" , ( ) => {
41
+ const queryString = `?a=b%23&x=y%25&j=`
42
+ cy . visit ( staticPath + queryString ) . waitForRouteChange ( )
43
+ cy . window ( ) . then ( win => {
44
+ expect ( win . location . search ) . to . equal ( queryString )
45
+ } )
46
+ } )
39
47
} )
40
48
41
49
describe ( `Param path ('${ paramPath } :param')` , ( ) => {
Original file line number Diff line number Diff line change @@ -209,9 +209,14 @@ export async function getData({
209
209
results . pageContext = page . context
210
210
211
211
let searchString = ``
212
+
212
213
if ( req ?. query ) {
213
214
const maybeQueryString = Object . entries ( req . query )
214
- . map ( ( [ k , v ] ) => `${ k } =${ v } ` )
215
+ . map (
216
+ ( [ k , v ] ) =>
217
+ // Preserve QueryString encoding
218
+ `${ encodeURIComponent ( k ) } =${ encodeURIComponent ( v as string ) } `
219
+ )
215
220
. join ( `&` )
216
221
if ( maybeQueryString ) {
217
222
searchString = `?${ maybeQueryString } `
You can’t perform that action at this time.
0 commit comments