Skip to content

Commit 9ac2652

Browse files
authored
Merge branch 'canary' into bump-nft-0-17-4
2 parents 85b296d + f5fb181 commit 9ac2652

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/next/server/base-server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,9 @@ export default abstract class Server {
510510
}
511511

512512
if (params) {
513-
params = utils.normalizeDynamicRouteParams(params).params
513+
if (!paramsResult.hasValidParams) {
514+
params = utils.normalizeDynamicRouteParams(params).params
515+
}
514516

515517
matchedPathname = utils.interpolateDynamicPath(
516518
matchedPathname,

test/production/required-server-files.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,23 @@ describe('should set-up next', () => {
671671
expect(json.url).toBe('/api/optional?another=value')
672672
})
673673

674+
it('should normalize index optional values correctly for API page', async () => {
675+
const res = await fetchViaHTTP(
676+
appPort,
677+
'/api/optional/index',
678+
{ rest: 'index', another: 'value' },
679+
{
680+
headers: {
681+
'x-matched-path': '/api/optional/[[...rest]]',
682+
},
683+
}
684+
)
685+
686+
const json = await res.json()
687+
expect(json.query).toEqual({ another: 'value', rest: ['index'] })
688+
expect(json.url).toBe('/api/optional/index?another=value')
689+
})
690+
674691
it('should match the index page correctly', async () => {
675692
const res = await fetchViaHTTP(appPort, '/', undefined, {
676693
headers: {

0 commit comments

Comments
 (0)