Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
c3d91491
Unverified
Commit
c3d91491
authored
Feb 24, 2020
by
Joe Haddad
Committed by
GitHub
Feb 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Double URL Encoding for Serverless (#10663)
parent
c3f11c20
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
next-serverless-loader.ts
...ages/next/build/webpack/loaders/next-serverless-loader.ts
+1
-1
[...slug].js
test/integration/serverless/pages/catchall/[...slug].js
+5
-0
index.test.js
test/integration/serverless/test/index.test.js
+22
-2
No files found.
packages/next/build/webpack/loaders/next-serverless-loader.ts
View file @
c3d91491
...
@@ -301,7 +301,7 @@ const nextServerlessLoader: loader.Loader = function() {
...
@@ -301,7 +301,7 @@ const nextServerlessLoader: loader.Loader = function() {
return Object.keys(obj).reduce(
return Object.keys(obj).reduce(
(prev, key) =>
(prev, key) =>
Object.assign(prev, {
Object.assign(prev, {
[key]:
encodeURIComponent(obj[key])
[key]:
obj[key]
}),
}),
{}
{}
);
);
...
...
test/integration/serverless/pages/catchall/[...slug].js
0 → 100644
View file @
c3d91491
const
SlugPage
=
({
query
})
=>
<
div
>
{
JSON
.
stringify
(
query
)}
<
/div
>
SlugPage
.
getInitialProps
=
({
query
})
=>
({
query
})
export
default
SlugPage
test/integration/serverless/test/index.test.js
View file @
c3d91491
...
@@ -251,10 +251,30 @@ describe('Serverless', () => {
...
@@ -251,10 +251,30 @@ describe('Serverless', () => {
expect
(
data
.
query
).
toEqual
({
slug
:
paramRaw
})
expect
(
data
.
query
).
toEqual
({
slug
:
paramRaw
})
})
})
it
(
'should have the correct query string for a
spr
route'
,
async
()
=>
{
it
(
'should have the correct query string for a
now
route'
,
async
()
=>
{
const
paramRaw
=
'test % 123'
const
paramRaw
=
'test % 123'
const
html
=
await
fetchViaHTTP
(
appPort
,
`/dr/[slug]`
,
''
,
{
const
html
=
await
fetchViaHTTP
(
appPort
,
`/dr/[slug]`
,
''
,
{
headers
:
{
'x-now-route-matches'
:
qs
.
stringify
({
1
:
paramRaw
})
},
headers
:
{
'x-now-route-matches'
:
qs
.
stringify
({
1
:
encodeURIComponent
(
paramRaw
),
}),
},
}).
then
(
res
=>
res
.
text
())
const
$
=
cheerio
.
load
(
html
)
const
data
=
JSON
.
parse
(
$
(
'#__NEXT_DATA__'
).
html
())
expect
(
data
.
query
).
toEqual
({
slug
:
paramRaw
})
})
it
(
'should have the correct query string for a catch all now route'
,
async
()
=>
{
const
paramRaw
=
[
'nested % 1'
,
'nested/2'
]
const
html
=
await
fetchViaHTTP
(
appPort
,
`/catchall/[...slug]`
,
''
,
{
headers
:
{
'x-now-route-matches'
:
qs
.
stringify
({
1
:
paramRaw
.
map
(
e
=>
encodeURIComponent
(
e
)).
join
(
'/'
),
}),
},
}).
then
(
res
=>
res
.
text
())
}).
then
(
res
=>
res
.
text
())
const
$
=
cheerio
.
load
(
html
)
const
$
=
cheerio
.
load
(
html
)
const
data
=
JSON
.
parse
(
$
(
'#__NEXT_DATA__'
).
html
())
const
data
=
JSON
.
parse
(
$
(
'#__NEXT_DATA__'
).
html
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment