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
7f28e8bf
Unverified
Commit
7f28e8bf
authored
May 15, 2020
by
JJ Kasper
Committed by
GitHub
May 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct multi-match param behavior (#12930)
parent
b280c82a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
5 deletions
+28
-5
router.ts
packages/next/next-server/server/router.ts
+1
-1
next.config.js
test/integration/custom-routes/next.config.js
+4
-0
index.test.js
test/integration/custom-routes/test/index.test.js
+19
-0
yarn.lock
yarn.lock
+4
-4
No files found.
packages/next/next-server/server/router.ts
View file @
7f28e8bf
...
@@ -69,7 +69,7 @@ export const prepareDestination = (
...
@@ -69,7 +69,7 @@ export const prepareDestination = (
if
(
appendParamsToQuery
)
{
if
(
appendParamsToQuery
)
{
for
(
const
[
name
,
value
]
of
Object
.
entries
(
params
))
{
for
(
const
[
name
,
value
]
of
Object
.
entries
(
params
))
{
if
(
!
(
name
in
destQuery
))
{
if
(
!
(
name
in
destQuery
))
{
destQuery
[
name
]
=
Array
.
isArray
(
value
)
?
value
.
join
(
'/'
)
:
value
destQuery
[
name
]
=
value
}
}
}
}
}
}
...
...
test/integration/custom-routes/next.config.js
View file @
7f28e8bf
...
@@ -87,6 +87,10 @@ module.exports = {
...
@@ -87,6 +87,10 @@ module.exports = {
source
:
'/unnamed-params/nested/(.*)/:test/(.*)'
,
source
:
'/unnamed-params/nested/(.*)/:test/(.*)'
,
destination
:
'/with-params'
,
destination
:
'/with-params'
,
},
},
{
source
:
'/catchall-rewrite/:path*'
,
destination
:
'/with-params'
,
},
]
]
},
},
async
redirects
()
{
async
redirects
()
{
...
...
test/integration/custom-routes/test/index.test.js
View file @
7f28e8bf
...
@@ -166,6 +166,18 @@ const runTests = (isDev = false) => {
...
@@ -166,6 +166,18 @@ const runTests = (isDev = false) => {
})
})
})
})
it
(
'should have correct params for catchall rewrite'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
appPort
,
'/catchall-rewrite/hello/world?a=b'
)
const
$
=
cheerio
.
load
(
html
)
expect
(
JSON
.
parse
(
$
(
'#__NEXT_DATA__'
).
html
()).
query
).
toEqual
({
a
:
'b'
,
path
:
[
'hello'
,
'world'
],
})
})
it
(
'should allow params in query for redirect'
,
async
()
=>
{
it
(
'should allow params in query for redirect'
,
async
()
=>
{
const
res
=
await
fetchViaHTTP
(
const
res
=
await
fetchViaHTTP
(
appPort
,
appPort
,
...
@@ -821,6 +833,13 @@ const runTests = (isDev = false) => {
...
@@ -821,6 +833,13 @@ const runTests = (isDev = false) => {
),
),
source
:
'/unnamed-params/nested/(.*)/:test/(.*)'
,
source
:
'/unnamed-params/nested/(.*)/:test/(.*)'
,
},
},
{
destination
:
'/with-params'
,
regex
:
normalizeRegEx
(
'^
\\
/catchall-rewrite(?:
\\
/((?:[^
\\
/]+?)(?:
\\
/(?:[^
\\
/]+?))*))?$'
),
source
:
'/catchall-rewrite/:path*'
,
},
],
],
dynamicRoutes
:
[
dynamicRoutes
:
[
{
{
...
...
yarn.lock
View file @
7f28e8bf
...
@@ -16059,10 +16059,10 @@ styled-components@5.1.0:
...
@@ -16059,10 +16059,10 @@ styled-components@5.1.0:
shallowequal "^1.1.0"
shallowequal "^1.1.0"
supports-color "^5.5.0"
supports-color "^5.5.0"
styled-jsx@3.
2.5
:
styled-jsx@3.
3.0
:
version "3.
2.5
"
version "3.
3.0
"
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-3.
2.5.tgz#0172a3e13a0d6d8bf09167dcaf32cf7102d932ca
"
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-3.
3.0.tgz#32335c1a3ecfc923ba4f9c056eeb3d4699006b09
"
integrity sha512-
prEahkYwQHomUljJzXzrFnBmQrSMtWOBbXn8QeEkpfFkqMZQGshxzzp4H8ebBIsbVlHF/3+GSXMnmK/fp7qVYQ
==
integrity sha512-
sh8BI5eGKyJlwL4kNXHjb27/a/GJV8wP4ElRIkRXrGW3sHKOsY9Pa1VZRNxyvf3+lisdPwizD9JDkzVO9uGwZw
==
dependencies:
dependencies:
"@babel/types" "7.8.3"
"@babel/types" "7.8.3"
babel-plugin-syntax-jsx "6.18.0"
babel-plugin-syntax-jsx "6.18.0"
...
...
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