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
c53b60a8
Unverified
Commit
c53b60a8
authored
Jul 06, 2021
by
JJ Kasper
Committed by
GitHub
Jul 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix forward slash encoding while interpolating (#26963)
parent
f8269fd4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
utils.ts
...ext/build/webpack/loaders/next-serverless-loader/utils.ts
+6
-3
index.test.js
test/integration/required-server-files/test/index.test.js
+22
-0
No files found.
packages/next/build/webpack/loaders/next-serverless-loader/utils.ts
View file @
c53b60a8
...
@@ -249,14 +249,17 @@ export function getUtils({
...
@@ -249,14 +249,17 @@ export function getUtils({
let
paramValue
:
string
let
paramValue
:
string
if
(
Array
.
isArray
(
params
[
param
]))
{
if
(
Array
.
isArray
(
params
[
param
]))
{
paramValue
=
(
params
[
param
]
as
string
[]).
join
(
'/'
)
paramValue
=
(
params
[
param
]
as
string
[])
.
map
((
v
)
=>
v
&&
encodeURIComponent
(
v
))
.
join
(
'/'
)
}
else
{
}
else
{
paramValue
=
params
[
param
]
as
string
paramValue
=
params
[
param
]
&&
encodeURIComponent
(
params
[
param
]
as
string
)
}
}
pathname
=
pathname
=
pathname
.
substr
(
0
,
paramIdx
)
+
pathname
.
substr
(
0
,
paramIdx
)
+
encodeURI
(
paramValue
||
''
)
+
(
paramValue
||
''
)
+
pathname
.
substr
(
paramIdx
+
builtParam
.
length
)
pathname
.
substr
(
paramIdx
+
builtParam
.
length
)
}
}
}
}
...
...
test/integration/required-server-files/test/index.test.js
View file @
c53b60a8
...
@@ -516,6 +516,28 @@ describe('Required Server Files', () => {
...
@@ -516,6 +516,28 @@ describe('Required Server Files', () => {
expect
(
props
.
params
).
toEqual
({})
expect
(
props
.
params
).
toEqual
({})
})
})
it
(
'should normalize optional values correctly for SSG page with encoded slash'
,
async
()
=>
{
const
res
=
await
fetchViaHTTP
(
appPort
,
'/optional-ssg/[[...rest]]'
,
undefined
,
{
headers
:
{
'x-matched-path'
:
'/optional-ssg/[[...rest]]'
,
'x-now-route-matches'
:
'1=en%2Fes%2Fhello%252Fworld&rest=en%2Fes%2Fhello%252Fworld'
,
},
}
)
const
html
=
await
res
.
text
()
const
$
=
cheerio
.
load
(
html
)
const
props
=
JSON
.
parse
(
$
(
'#props'
).
text
())
expect
(
props
.
params
).
toEqual
({
rest
:
[
'en'
,
'es'
,
'hello/world'
],
})
})
it
(
'should normalize optional values correctly for API page'
,
async
()
=>
{
it
(
'should normalize optional values correctly for API page'
,
async
()
=>
{
const
res
=
await
fetchViaHTTP
(
const
res
=
await
fetchViaHTTP
(
appPort
,
appPort
,
...
...
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