Unverified Commit 7f28e8bf authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Correct multi-match param behavior (#12930)

parent b280c82a
......@@ -69,7 +69,7 @@ export const prepareDestination = (
if (appendParamsToQuery) {
for (const [name, value] of Object.entries(params)) {
if (!(name in destQuery)) {
destQuery[name] = Array.isArray(value) ? value.join('/') : value
destQuery[name] = value
}
}
}
......
......@@ -87,6 +87,10 @@ module.exports = {
source: '/unnamed-params/nested/(.*)/:test/(.*)',
destination: '/with-params',
},
{
source: '/catchall-rewrite/:path*',
destination: '/with-params',
},
]
},
async redirects() {
......
......@@ -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 () => {
const res = await fetchViaHTTP(
appPort,
......@@ -821,6 +833,13 @@ const runTests = (isDev = false) => {
),
source: '/unnamed-params/nested/(.*)/:test/(.*)',
},
{
destination: '/with-params',
regex: normalizeRegEx(
'^\\/catchall-rewrite(?:\\/((?:[^\\/]+?)(?:\\/(?:[^\\/]+?))*))?$'
),
source: '/catchall-rewrite/:path*',
},
],
dynamicRoutes: [
{
......
......@@ -16059,10 +16059,10 @@ styled-components@5.1.0:
shallowequal "^1.1.0"
supports-color "^5.5.0"
styled-jsx@3.2.5:
version "3.2.5"
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-3.2.5.tgz#0172a3e13a0d6d8bf09167dcaf32cf7102d932ca"
integrity sha512-prEahkYwQHomUljJzXzrFnBmQrSMtWOBbXn8QeEkpfFkqMZQGshxzzp4H8ebBIsbVlHF/3+GSXMnmK/fp7qVYQ==
styled-jsx@3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-3.3.0.tgz#32335c1a3ecfc923ba4f9c056eeb3d4699006b09"
integrity sha512-sh8BI5eGKyJlwL4kNXHjb27/a/GJV8wP4ElRIkRXrGW3sHKOsY9Pa1VZRNxyvf3+lisdPwizD9JDkzVO9uGwZw==
dependencies:
"@babel/types" "7.8.3"
babel-plugin-syntax-jsx "6.18.0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment