Unverified Commit 40687dae authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update query param prefix to reduce length (#48051)

With the addition of the query prefix we can hit the max length for PCRE
named matches so this reduces the prefix length and ensures we go
through the param name validation still

x-ref: https://twitter.com/simonecervini/status/1644123851003928579
parent 690208b1
import type { ServerRuntime } from '../../types' import type { ServerRuntime } from '../../types'
export const NEXT_QUERY_PARAM_PREFIX = 'nextParam' export const NEXT_QUERY_PARAM_PREFIX = 'nxtP'
// in seconds // in seconds
export const CACHE_ONE_YEAR = 31536000 export const CACHE_ONE_YEAR = 31536000
......
import { escapeStringRegexp } from '../../escape-regexp' import { escapeStringRegexp } from '../../escape-regexp'
import { removeTrailingSlash } from './remove-trailing-slash' import { removeTrailingSlash } from './remove-trailing-slash'
const NEXT_QUERY_PARAM_PREFIX = 'nextParam' const NEXT_QUERY_PARAM_PREFIX = 'nxtP'
export interface Group { export interface Group {
pos: number pos: number
...@@ -102,6 +102,10 @@ function getNamedParametrizedRoute(route: string, prefixRouteKeys: boolean) { ...@@ -102,6 +102,10 @@ function getNamedParametrizedRoute(route: string, prefixRouteKeys: boolean) {
// replace any non-word characters since they can break // replace any non-word characters since they can break
// the named regex // the named regex
let cleanedKey = key.replace(/\W/g, '') let cleanedKey = key.replace(/\W/g, '')
if (prefixRouteKeys) {
cleanedKey = `${NEXT_QUERY_PARAM_PREFIX}${cleanedKey}`
}
let invalidKey = false let invalidKey = false
// check if the key is still invalid and fallback to using a known // check if the key is still invalid and fallback to using a known
...@@ -118,7 +122,6 @@ function getNamedParametrizedRoute(route: string, prefixRouteKeys: boolean) { ...@@ -118,7 +122,6 @@ function getNamedParametrizedRoute(route: string, prefixRouteKeys: boolean) {
} }
if (prefixRouteKeys) { if (prefixRouteKeys) {
cleanedKey = `${NEXT_QUERY_PARAM_PREFIX}${cleanedKey}`
routeKeys[cleanedKey] = `${NEXT_QUERY_PARAM_PREFIX}${key}` routeKeys[cleanedKey] = `${NEXT_QUERY_PARAM_PREFIX}${key}`
} else { } else {
routeKeys[cleanedKey] = `${key}` routeKeys[cleanedKey] = `${key}`
......
...@@ -140,10 +140,10 @@ describe('edge-render-getserversideprops', () => { ...@@ -140,10 +140,10 @@ describe('edge-render-getserversideprops', () => {
), ),
namedDataRouteRegex: `^/_next/data/${escapeStringRegexp( namedDataRouteRegex: `^/_next/data/${escapeStringRegexp(
next.buildId next.buildId
)}/(?<nextParamid>[^/]+?)\\.json$`, )}/(?<nxtPid>[^/]+?)\\.json$`,
page: '/[id]', page: '/[id]',
routeKeys: { routeKeys: {
nextParamid: 'nextParamid', nxtPid: 'nxtPid',
}, },
}, },
]) ])
......
...@@ -43,19 +43,19 @@ const expectedManifestRoutes = () => [ ...@@ -43,19 +43,19 @@ const expectedManifestRoutes = () => [
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/blog/(?<nextParampost>[^/]+?)\\.json$`, )}/blog/(?<nxtPpost>[^/]+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex(buildId)}\\/blog\\/([^\\/]+?)\\.json$` `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/blog\\/([^\\/]+?)\\.json$`
), ),
page: '/blog/[post]', page: '/blog/[post]',
routeKeys: { routeKeys: {
nextParampost: 'nextParampost', nxtPpost: 'nxtPpost',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/blog/(?<nextParampost>[^/]+?)/(?<nextParamcomment>[^/]+?)\\.json$`, )}/blog/(?<nxtPpost>[^/]+?)/(?<nxtPcomment>[^/]+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
buildId buildId
...@@ -63,20 +63,20 @@ const expectedManifestRoutes = () => [ ...@@ -63,20 +63,20 @@ const expectedManifestRoutes = () => [
), ),
page: '/blog/[post]/[comment]', page: '/blog/[post]/[comment]',
routeKeys: { routeKeys: {
nextParampost: 'nextParampost', nxtPpost: 'nxtPpost',
nextParamcomment: 'nextParamcomment', nxtPcomment: 'nxtPcomment',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/catchall/(?<nextParampath>.+?)\\.json$`, )}/catchall/(?<nxtPpath>.+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex(buildId)}\\/catchall\\/(.+?)\\.json$` `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/catchall\\/(.+?)\\.json$`
), ),
page: '/catchall/[...path]', page: '/catchall/[...path]',
routeKeys: { routeKeys: {
nextParampath: 'nextParampath', nxtPpath: 'nxtPpath',
}, },
}, },
{ {
...@@ -127,10 +127,10 @@ const expectedManifestRoutes = () => [ ...@@ -127,10 +127,10 @@ const expectedManifestRoutes = () => [
)}\\/not\\-found\\/([^\\/]+?)\\.json$`, )}\\/not\\-found\\/([^\\/]+?)\\.json$`,
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/not\\-found/(?<nextParamslug>[^/]+?)\\.json$`, )}/not\\-found/(?<nxtPslug>[^/]+?)\\.json$`,
page: '/not-found/[slug]', page: '/not-found/[slug]',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
...@@ -182,7 +182,7 @@ const expectedManifestRoutes = () => [ ...@@ -182,7 +182,7 @@ const expectedManifestRoutes = () => [
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/user/(?<nextParamuser>[^/]+?)/profile\\.json$`, )}/user/(?<nxtPuser>[^/]+?)/profile\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
buildId buildId
...@@ -190,7 +190,7 @@ const expectedManifestRoutes = () => [ ...@@ -190,7 +190,7 @@ const expectedManifestRoutes = () => [
), ),
page: '/user/[user]/profile', page: '/user/[user]/profile',
routeKeys: { routeKeys: {
nextParamuser: 'nextParamuser', nxtPuser: 'nxtPuser',
}, },
}, },
] ]
......
...@@ -1316,10 +1316,10 @@ describe('Prerender', () => { ...@@ -1316,10 +1316,10 @@ describe('Prerender', () => {
), ),
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/api\\-docs/(?<nextParamslug>.+?)\\.json$`, )}/api\\-docs/(?<nxtPslug>.+?)\\.json$`,
page: '/api-docs/[...slug]', page: '/api-docs/[...slug]',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
...@@ -1346,9 +1346,9 @@ describe('Prerender', () => { ...@@ -1346,9 +1346,9 @@ describe('Prerender', () => {
), ),
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/blocking\\-fallback/(?<nextParamslug>[^/]+?)\\.json$`, )}/blocking\\-fallback/(?<nxtPslug>[^/]+?)\\.json$`,
page: '/blocking-fallback/[slug]', page: '/blocking-fallback/[slug]',
routeKeys: { nextParamslug: 'nextParamslug' }, routeKeys: { nxtPslug: 'nxtPslug' },
}, },
{ {
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
...@@ -1358,9 +1358,9 @@ describe('Prerender', () => { ...@@ -1358,9 +1358,9 @@ describe('Prerender', () => {
), ),
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/blocking\\-fallback\\-once/(?<nextParamslug>[^/]+?)\\.json$`, )}/blocking\\-fallback\\-once/(?<nxtPslug>[^/]+?)\\.json$`,
page: '/blocking-fallback-once/[slug]', page: '/blocking-fallback-once/[slug]',
routeKeys: { nextParamslug: 'nextParamslug' }, routeKeys: { nxtPslug: 'nxtPslug' },
}, },
{ {
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
...@@ -1370,9 +1370,9 @@ describe('Prerender', () => { ...@@ -1370,9 +1370,9 @@ describe('Prerender', () => {
), ),
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/blocking\\-fallback\\-some/(?<nextParamslug>[^/]+?)\\.json$`, )}/blocking\\-fallback\\-some/(?<nxtPslug>[^/]+?)\\.json$`,
page: '/blocking-fallback-some/[slug]', page: '/blocking-fallback-some/[slug]',
routeKeys: { nextParamslug: 'nextParamslug' }, routeKeys: { nxtPslug: 'nxtPslug' },
}, },
{ {
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
...@@ -1383,7 +1383,7 @@ describe('Prerender', () => { ...@@ -1383,7 +1383,7 @@ describe('Prerender', () => {
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/blog/(?<nextParampost>[^/]+?)\\.json$`, )}/blog/(?<nxtPpost>[^/]+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
next.buildId next.buildId
...@@ -1391,13 +1391,13 @@ describe('Prerender', () => { ...@@ -1391,13 +1391,13 @@ describe('Prerender', () => {
), ),
page: '/blog/[post]', page: '/blog/[post]',
routeKeys: { routeKeys: {
nextParampost: 'nextParampost', nxtPpost: 'nxtPpost',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/blog/(?<nextParampost>[^/]+?)/(?<nextParamcomment>[^/]+?)\\.json$`, )}/blog/(?<nxtPpost>[^/]+?)/(?<nxtPcomment>[^/]+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
next.buildId next.buildId
...@@ -1405,14 +1405,14 @@ describe('Prerender', () => { ...@@ -1405,14 +1405,14 @@ describe('Prerender', () => {
), ),
page: '/blog/[post]/[comment]', page: '/blog/[post]/[comment]',
routeKeys: { routeKeys: {
nextParampost: 'nextParampost', nxtPpost: 'nxtPpost',
nextParamcomment: 'nextParamcomment', nxtPcomment: 'nxtPcomment',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/catchall/(?<nextParamslug>.+?)\\.json$`, )}/catchall/(?<nxtPslug>.+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
next.buildId next.buildId
...@@ -1420,13 +1420,13 @@ describe('Prerender', () => { ...@@ -1420,13 +1420,13 @@ describe('Prerender', () => {
), ),
page: '/catchall/[...slug]', page: '/catchall/[...slug]',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/catchall\\-explicit/(?<nextParamslug>.+?)\\.json$`, )}/catchall\\-explicit/(?<nxtPslug>.+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
next.buildId next.buildId
...@@ -1434,13 +1434,13 @@ describe('Prerender', () => { ...@@ -1434,13 +1434,13 @@ describe('Prerender', () => {
), ),
page: '/catchall-explicit/[...slug]', page: '/catchall-explicit/[...slug]',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/catchall\\-optional(?:/(?<nextParamslug>.+?))?\\.json$`, )}/catchall\\-optional(?:/(?<nxtPslug>.+?))?\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
next.buildId next.buildId
...@@ -1448,7 +1448,7 @@ describe('Prerender', () => { ...@@ -1448,7 +1448,7 @@ describe('Prerender', () => {
), ),
page: '/catchall-optional/[[...slug]]', page: '/catchall-optional/[[...slug]]',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
...@@ -1467,10 +1467,10 @@ describe('Prerender', () => { ...@@ -1467,10 +1467,10 @@ describe('Prerender', () => {
), ),
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/dynamic/(?<nextParamslug>[^/]+?)\\.json$`, )}/dynamic/(?<nxtPslug>[^/]+?)\\.json$`,
page: '/dynamic/[slug]', page: '/dynamic/[slug]',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
...@@ -1481,10 +1481,10 @@ describe('Prerender', () => { ...@@ -1481,10 +1481,10 @@ describe('Prerender', () => {
), ),
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/fallback\\-only/(?<nextParamslug>[^/]+?)\\.json$`, )}/fallback\\-only/(?<nxtPslug>[^/]+?)\\.json$`,
page: '/fallback-only/[slug]', page: '/fallback-only/[slug]',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
// TODO: investigate index/index // TODO: investigate index/index
...@@ -1499,7 +1499,7 @@ describe('Prerender', () => { ...@@ -1499,7 +1499,7 @@ describe('Prerender', () => {
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/lang/(?<nextParamlang>[^/]+?)/about\\.json$`, )}/lang/(?<nxtPlang>[^/]+?)/about\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
next.buildId next.buildId
...@@ -1507,7 +1507,7 @@ describe('Prerender', () => { ...@@ -1507,7 +1507,7 @@ describe('Prerender', () => {
), ),
page: '/lang/[lang]/about', page: '/lang/[lang]/about',
routeKeys: { routeKeys: {
nextParamlang: 'nextParamlang', nxtPlang: 'nxtPlang',
}, },
}, },
{ {
...@@ -1525,7 +1525,7 @@ describe('Prerender', () => { ...@@ -1525,7 +1525,7 @@ describe('Prerender', () => {
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/non\\-json/(?<nextParamp>[^/]+?)\\.json$`, )}/non\\-json/(?<nxtPp>[^/]+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
next.buildId next.buildId
...@@ -1533,13 +1533,13 @@ describe('Prerender', () => { ...@@ -1533,13 +1533,13 @@ describe('Prerender', () => {
), ),
page: '/non-json/[p]', page: '/non-json/[p]',
routeKeys: { routeKeys: {
nextParamp: 'nextParamp', nxtPp: 'nxtPp',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/non\\-json\\-blocking/(?<nextParamp>[^/]+?)\\.json$`, )}/non\\-json\\-blocking/(?<nxtPp>[^/]+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
next.buildId next.buildId
...@@ -1547,7 +1547,7 @@ describe('Prerender', () => { ...@@ -1547,7 +1547,7 @@ describe('Prerender', () => {
), ),
page: '/non-json-blocking/[p]', page: '/non-json-blocking/[p]',
routeKeys: { routeKeys: {
nextParamp: 'nextParamp', nxtPp: 'nxtPp',
}, },
}, },
{ {
...@@ -1575,7 +1575,7 @@ describe('Prerender', () => { ...@@ -1575,7 +1575,7 @@ describe('Prerender', () => {
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
next.buildId next.buildId
)}/user/(?<nextParamuser>[^/]+?)/profile\\.json$`, )}/user/(?<nxtPuser>[^/]+?)/profile\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
next.buildId next.buildId
...@@ -1583,7 +1583,7 @@ describe('Prerender', () => { ...@@ -1583,7 +1583,7 @@ describe('Prerender', () => {
), ),
page: '/user/[user]/profile', page: '/user/[user]/profile',
routeKeys: { routeKeys: {
nextParamuser: 'nextParamuser', nxtPuser: 'nxtPuser',
}, },
}, },
]) ])
......
...@@ -1544,10 +1544,10 @@ const runTests = (isDev = false, isTurbo = false) => { ...@@ -1544,10 +1544,10 @@ const runTests = (isDev = false, isTurbo = false) => {
), ),
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/blog\\-catchall/(?<nextParamslug>.+?)\\.json$`, )}/blog\\-catchall/(?<nxtPslug>.+?)\\.json$`,
page: '/blog-catchall/[...slug]', page: '/blog-catchall/[...slug]',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
...@@ -1556,10 +1556,10 @@ const runTests = (isDev = false, isTurbo = false) => { ...@@ -1556,10 +1556,10 @@ const runTests = (isDev = false, isTurbo = false) => {
)}\\/overridden\\/([^\\/]+?)\\.json$`, )}\\/overridden\\/([^\\/]+?)\\.json$`,
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/overridden/(?<nextParamslug>[^/]+?)\\.json$`, )}/overridden/(?<nxtPslug>[^/]+?)\\.json$`,
page: '/overridden/[slug]', page: '/overridden/[slug]',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
], ],
...@@ -2464,67 +2464,67 @@ const runTests = (isDev = false, isTurbo = false) => { ...@@ -2464,67 +2464,67 @@ const runTests = (isDev = false, isTurbo = false) => {
}, },
dynamicRoutes: [ dynamicRoutes: [
{ {
namedRegex: '^/_sport/(?<nextParamslug>[^/]+?)(?:/)?$', namedRegex: '^/_sport/(?<nxtPslug>[^/]+?)(?:/)?$',
page: '/_sport/[slug]', page: '/_sport/[slug]',
regex: normalizeRegEx('^\\/_sport\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/_sport\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
namedRegex: '^/_sport/(?<nextParamslug>[^/]+?)/test(?:/)?$', namedRegex: '^/_sport/(?<nxtPslug>[^/]+?)/test(?:/)?$',
page: '/_sport/[slug]/test', page: '/_sport/[slug]/test',
regex: normalizeRegEx('^\\/_sport\\/([^\\/]+?)\\/test(?:\\/)?$'), regex: normalizeRegEx('^\\/_sport\\/([^\\/]+?)\\/test(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
namedRegex: '^/another/(?<nextParamid>[^/]+?)(?:/)?$', namedRegex: '^/another/(?<nxtPid>[^/]+?)(?:/)?$',
page: '/another/[id]', page: '/another/[id]',
regex: normalizeRegEx('^\\/another\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/another\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamid: 'nextParamid', nxtPid: 'nxtPid',
}, },
}, },
{ {
namedRegex: '^/api/dynamic/(?<nextParamslug>[^/]+?)(?:/)?$', namedRegex: '^/api/dynamic/(?<nxtPslug>[^/]+?)(?:/)?$',
page: '/api/dynamic/[slug]', page: '/api/dynamic/[slug]',
regex: normalizeRegEx('^\\/api\\/dynamic\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/api\\/dynamic\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
namedRegex: '^/auto\\-export/(?<nextParamslug>[^/]+?)(?:/)?$', namedRegex: '^/auto\\-export/(?<nxtPslug>[^/]+?)(?:/)?$',
page: '/auto-export/[slug]', page: '/auto-export/[slug]',
regex: normalizeRegEx('^\\/auto\\-export\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/auto\\-export\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
namedRegex: '^/blog/(?<nextParampost>[^/]+?)(?:/)?$', namedRegex: '^/blog/(?<nxtPpost>[^/]+?)(?:/)?$',
page: '/blog/[post]', page: '/blog/[post]',
regex: normalizeRegEx('^\\/blog\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/blog\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParampost: 'nextParampost', nxtPpost: 'nxtPpost',
}, },
}, },
{ {
namedRegex: '^/blog\\-catchall/(?<nextParamslug>.+?)(?:/)?$', namedRegex: '^/blog\\-catchall/(?<nxtPslug>.+?)(?:/)?$',
page: '/blog-catchall/[...slug]', page: '/blog-catchall/[...slug]',
regex: normalizeRegEx('^\\/blog\\-catchall\\/(.+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/blog\\-catchall\\/(.+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
namedRegex: '^/overridden/(?<nextParamslug>[^/]+?)(?:/)?$', namedRegex: '^/overridden/(?<nxtPslug>[^/]+?)(?:/)?$',
page: '/overridden/[slug]', page: '/overridden/[slug]',
regex: '^\\/overridden\\/([^\\/]+?)(?:\\/)?$', regex: '^\\/overridden\\/([^\\/]+?)(?:\\/)?$',
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
], ],
......
...@@ -1257,10 +1257,10 @@ function runTests({ dev }) { ...@@ -1257,10 +1257,10 @@ function runTests({ dev }) {
)}\\/b\\/([^\\/]+?)\\.json$`, )}\\/b\\/([^\\/]+?)\\.json$`,
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/b/(?<nextParama>[^/]+?)\\.json$`, )}/b/(?<nxtP123>[^/]+?)\\.json$`,
page: '/b/[123]', page: '/b/[123]',
routeKeys: { routeKeys: {
nextParama: 'nextParam123', nxtP123: 'nxtP123',
}, },
}, },
{ {
...@@ -1269,17 +1269,16 @@ function runTests({ dev }) { ...@@ -1269,17 +1269,16 @@ function runTests({ dev }) {
)}\\/c\\/([^\\/]+?)\\.json$`, )}\\/c\\/([^\\/]+?)\\.json$`,
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/c/(?<nextParama>[^/]+?)\\.json$`, )}/c/(?<a>[^/]+?)\\.json$`,
page: '/c/[alongparamnameshouldbeallowedeventhoughweird]', page: '/c/[alongparamnameshouldbeallowedeventhoughweird]',
routeKeys: { routeKeys: {
nextParama: a: 'nxtPalongparamnameshouldbeallowedeventhoughweird',
'nextParamalongparamnameshouldbeallowedeventhoughweird',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/p1/p2/all\\-ssg/(?<nextParamrest>.+?)\\.json$`, )}/p1/p2/all\\-ssg/(?<nxtPrest>.+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
buildId buildId
...@@ -1287,13 +1286,13 @@ function runTests({ dev }) { ...@@ -1287,13 +1286,13 @@ function runTests({ dev }) {
), ),
page: '/p1/p2/all-ssg/[...rest]', page: '/p1/p2/all-ssg/[...rest]',
routeKeys: { routeKeys: {
nextParamrest: 'nextParamrest', nxtPrest: 'nxtPrest',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/p1/p2/nested\\-all\\-ssg/(?<nextParamrest>.+?)\\.json$`, )}/p1/p2/nested\\-all\\-ssg/(?<nxtPrest>.+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
buildId buildId
...@@ -1301,13 +1300,13 @@ function runTests({ dev }) { ...@@ -1301,13 +1300,13 @@ function runTests({ dev }) {
), ),
page: '/p1/p2/nested-all-ssg/[...rest]', page: '/p1/p2/nested-all-ssg/[...rest]',
routeKeys: { routeKeys: {
nextParamrest: 'nextParamrest', nxtPrest: 'nxtPrest',
}, },
}, },
{ {
namedDataRouteRegex: `^/_next/data/${escapeRegex( namedDataRouteRegex: `^/_next/data/${escapeRegex(
buildId buildId
)}/p1/p2/predefined\\-ssg/(?<nextParamrest>.+?)\\.json$`, )}/p1/p2/predefined\\-ssg/(?<nxtPrest>.+?)\\.json$`,
dataRouteRegex: normalizeRegEx( dataRouteRegex: normalizeRegEx(
`^\\/_next\\/data\\/${escapeRegex( `^\\/_next\\/data\\/${escapeRegex(
buildId buildId
...@@ -1315,148 +1314,147 @@ function runTests({ dev }) { ...@@ -1315,148 +1314,147 @@ function runTests({ dev }) {
), ),
page: '/p1/p2/predefined-ssg/[...rest]', page: '/p1/p2/predefined-ssg/[...rest]',
routeKeys: { routeKeys: {
nextParamrest: 'nextParamrest', nxtPrest: 'nxtPrest',
}, },
}, },
], ],
dynamicRoutes: [ dynamicRoutes: [
{ {
namedRegex: '^/b/(?<nextParama>[^/]+?)(?:/)?$', namedRegex: '^/b/(?<nxtP123>[^/]+?)(?:/)?$',
page: '/b/[123]', page: '/b/[123]',
regex: normalizeRegEx('^\\/b\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/b\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParama: 'nextParam123', nxtP123: 'nxtP123',
}, },
}, },
{ {
namedRegex: `^/blog/(?<nextParamname>[^/]+?)/comment/(?<nextParamid>[^/]+?)(?:/)?$`, namedRegex: `^/blog/(?<nxtPname>[^/]+?)/comment/(?<nxtPid>[^/]+?)(?:/)?$`,
page: '/blog/[name]/comment/[id]', page: '/blog/[name]/comment/[id]',
regex: normalizeRegEx( regex: normalizeRegEx(
'^\\/blog\\/([^\\/]+?)\\/comment\\/([^\\/]+?)(?:\\/)?$' '^\\/blog\\/([^\\/]+?)\\/comment\\/([^\\/]+?)(?:\\/)?$'
), ),
routeKeys: { routeKeys: {
nextParamname: 'nextParamname', nxtPname: 'nxtPname',
nextParamid: 'nextParamid', nxtPid: 'nxtPid',
}, },
}, },
{ {
namedRegex: '^/c/(?<nextParama>[^/]+?)(?:/)?$', namedRegex: '^/c/(?<a>[^/]+?)(?:/)?$',
page: '/c/[alongparamnameshouldbeallowedeventhoughweird]', page: '/c/[alongparamnameshouldbeallowedeventhoughweird]',
regex: normalizeRegEx('^\\/c\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/c\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParama: a: 'nxtPalongparamnameshouldbeallowedeventhoughweird',
'nextParamalongparamnameshouldbeallowedeventhoughweird',
}, },
}, },
{ {
namedRegex: '^/catchall\\-dash/(?<nextParamhelloworld>.+?)(?:/)?$', namedRegex: '^/catchall\\-dash/(?<nxtPhelloworld>.+?)(?:/)?$',
page: '/catchall-dash/[...hello-world]', page: '/catchall-dash/[...hello-world]',
regex: normalizeRegEx('^\\/catchall\\-dash\\/(.+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/catchall\\-dash\\/(.+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamhelloworld: 'nextParamhello-world', nxtPhelloworld: 'nxtPhello-world',
}, },
}, },
{ {
namedRegex: '^/d/(?<nextParamid>[^/]+?)(?:/)?$', namedRegex: '^/d/(?<nxtPid>[^/]+?)(?:/)?$',
page: '/d/[id]', page: '/d/[id]',
regex: normalizeRegEx('^\\/d\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/d\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamid: 'nextParamid', nxtPid: 'nxtPid',
}, },
}, },
{ {
namedRegex: '^/dash/(?<nextParamhelloworld>[^/]+?)(?:/)?$', namedRegex: '^/dash/(?<nxtPhelloworld>[^/]+?)(?:/)?$',
page: '/dash/[hello-world]', page: '/dash/[hello-world]',
regex: normalizeRegEx('^\\/dash\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/dash\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamhelloworld: 'nextParamhello-world', nxtPhelloworld: 'nxtPhello-world',
}, },
}, },
{ {
namedRegex: '^/index/(?<nextParamslug>.+?)(?:/)?$', namedRegex: '^/index/(?<nxtPslug>.+?)(?:/)?$',
page: '/index/[...slug]', page: '/index/[...slug]',
regex: normalizeRegEx('^/index/(.+?)(?:/)?$'), regex: normalizeRegEx('^/index/(.+?)(?:/)?$'),
routeKeys: { routeKeys: {
nextParamslug: 'nextParamslug', nxtPslug: 'nxtPslug',
}, },
}, },
{ {
namedRegex: `^/on\\-mount/(?<nextParampost>[^/]+?)(?:/)?$`, namedRegex: `^/on\\-mount/(?<nxtPpost>[^/]+?)(?:/)?$`,
page: '/on-mount/[post]', page: '/on-mount/[post]',
regex: normalizeRegEx('^\\/on\\-mount\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/on\\-mount\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParampost: 'nextParampost', nxtPpost: 'nxtPpost',
}, },
}, },
{ {
namedRegex: `^/p1/p2/all\\-ssg/(?<nextParamrest>.+?)(?:/)?$`, namedRegex: `^/p1/p2/all\\-ssg/(?<nxtPrest>.+?)(?:/)?$`,
page: '/p1/p2/all-ssg/[...rest]', page: '/p1/p2/all-ssg/[...rest]',
regex: normalizeRegEx('^\\/p1\\/p2\\/all\\-ssg\\/(.+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/p1\\/p2\\/all\\-ssg\\/(.+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamrest: 'nextParamrest', nxtPrest: 'nxtPrest',
}, },
}, },
{ {
namedRegex: `^/p1/p2/all\\-ssr/(?<nextParamrest>.+?)(?:/)?$`, namedRegex: `^/p1/p2/all\\-ssr/(?<nxtPrest>.+?)(?:/)?$`,
page: '/p1/p2/all-ssr/[...rest]', page: '/p1/p2/all-ssr/[...rest]',
regex: normalizeRegEx('^\\/p1\\/p2\\/all\\-ssr\\/(.+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/p1\\/p2\\/all\\-ssr\\/(.+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamrest: 'nextParamrest', nxtPrest: 'nxtPrest',
}, },
}, },
{ {
namedRegex: `^/p1/p2/nested\\-all\\-ssg/(?<nextParamrest>.+?)(?:/)?$`, namedRegex: `^/p1/p2/nested\\-all\\-ssg/(?<nxtPrest>.+?)(?:/)?$`,
page: '/p1/p2/nested-all-ssg/[...rest]', page: '/p1/p2/nested-all-ssg/[...rest]',
regex: normalizeRegEx( regex: normalizeRegEx(
'^\\/p1\\/p2\\/nested\\-all\\-ssg\\/(.+?)(?:\\/)?$' '^\\/p1\\/p2\\/nested\\-all\\-ssg\\/(.+?)(?:\\/)?$'
), ),
routeKeys: { routeKeys: {
nextParamrest: 'nextParamrest', nxtPrest: 'nxtPrest',
}, },
}, },
{ {
namedRegex: `^/p1/p2/predefined\\-ssg/(?<nextParamrest>.+?)(?:/)?$`, namedRegex: `^/p1/p2/predefined\\-ssg/(?<nxtPrest>.+?)(?:/)?$`,
page: '/p1/p2/predefined-ssg/[...rest]', page: '/p1/p2/predefined-ssg/[...rest]',
regex: normalizeRegEx( regex: normalizeRegEx(
'^\\/p1\\/p2\\/predefined\\-ssg\\/(.+?)(?:\\/)?$' '^\\/p1\\/p2\\/predefined\\-ssg\\/(.+?)(?:\\/)?$'
), ),
routeKeys: { routeKeys: {
nextParamrest: 'nextParamrest', nxtPrest: 'nxtPrest',
}, },
}, },
{ {
namedRegex: `^/(?<nextParamname>[^/]+?)(?:/)?$`, namedRegex: `^/(?<nxtPname>[^/]+?)(?:/)?$`,
page: '/[name]', page: '/[name]',
regex: normalizeRegEx('^\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamname: 'nextParamname', nxtPname: 'nxtPname',
}, },
}, },
{ {
namedRegex: `^/(?<nextParamname>[^/]+?)/comments(?:/)?$`, namedRegex: `^/(?<nxtPname>[^/]+?)/comments(?:/)?$`,
page: '/[name]/comments', page: '/[name]/comments',
regex: normalizeRegEx('^\\/([^\\/]+?)\\/comments(?:\\/)?$'), regex: normalizeRegEx('^\\/([^\\/]+?)\\/comments(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamname: 'nextParamname', nxtPname: 'nxtPname',
}, },
}, },
{ {
namedRegex: `^/(?<nextParamname>[^/]+?)/on\\-mount\\-redir(?:/)?$`, namedRegex: `^/(?<nxtPname>[^/]+?)/on\\-mount\\-redir(?:/)?$`,
page: '/[name]/on-mount-redir', page: '/[name]/on-mount-redir',
regex: normalizeRegEx( regex: normalizeRegEx(
'^\\/([^\\/]+?)\\/on\\-mount\\-redir(?:\\/)?$' '^\\/([^\\/]+?)\\/on\\-mount\\-redir(?:\\/)?$'
), ),
routeKeys: { routeKeys: {
nextParamname: 'nextParamname', nxtPname: 'nxtPname',
}, },
}, },
{ {
namedRegex: `^/(?<nextParamname>[^/]+?)/(?<nextParamcomment>[^/]+?)(?:/)?$`, namedRegex: `^/(?<nxtPname>[^/]+?)/(?<nxtPcomment>[^/]+?)(?:/)?$`,
page: '/[name]/[comment]', page: '/[name]/[comment]',
regex: normalizeRegEx('^\\/([^\\/]+?)\\/([^\\/]+?)(?:\\/)?$'), regex: normalizeRegEx('^\\/([^\\/]+?)\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: { routeKeys: {
nextParamname: 'nextParamname', nxtPname: 'nxtPname',
nextParamcomment: 'nextParamcomment', nxtPcomment: 'nxtPcomment',
}, },
}, },
], ],
......
...@@ -193,7 +193,7 @@ describe('Required Server Files', () => { ...@@ -193,7 +193,7 @@ describe('Required Server Files', () => {
it('should render dynamic SSR page correctly with x-matched-path', async () => { it('should render dynamic SSR page correctly with x-matched-path', async () => {
const html = await renderViaHTTP( const html = await renderViaHTTP(
appPort, appPort,
'/some-other-path?nextParamslug=first', '/some-other-path?nxtPslug=first',
undefined, undefined,
{ {
headers: { headers: {
...@@ -259,7 +259,7 @@ describe('Required Server Files', () => { ...@@ -259,7 +259,7 @@ describe('Required Server Files', () => {
it('should return data correctly with x-matched-path', async () => { it('should return data correctly with x-matched-path', async () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
appPort, appPort,
`/_next/data/${buildId}/dynamic/first.json?nextParamslug=first`, `/_next/data/${buildId}/dynamic/first.json?nxtPslug=first`,
undefined, undefined,
{ {
headers: { headers: {
......
...@@ -313,7 +313,7 @@ describe('should set-up next', () => { ...@@ -313,7 +313,7 @@ describe('should set-up next', () => {
it('should render dynamic SSR page correctly with x-matched-path', async () => { it('should render dynamic SSR page correctly with x-matched-path', async () => {
const html = await renderViaHTTP( const html = await renderViaHTTP(
appPort, appPort,
'/some-other-path?nextParamslug=first', '/some-other-path?nxtPslug=first',
undefined, undefined,
{ {
headers: { headers: {
...@@ -330,7 +330,7 @@ describe('should set-up next', () => { ...@@ -330,7 +330,7 @@ describe('should set-up next', () => {
const html2 = await renderViaHTTP( const html2 = await renderViaHTTP(
appPort, appPort,
'/some-other-path?nextParamslug=second', '/some-other-path?nxtPslug=second',
undefined, undefined,
{ {
headers: { headers: {
...@@ -349,7 +349,7 @@ describe('should set-up next', () => { ...@@ -349,7 +349,7 @@ describe('should set-up next', () => {
const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, { const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, {
headers: { headers: {
'x-matched-path': '/dynamic/[slug]?slug=%5Bslug%5D.json', 'x-matched-path': '/dynamic/[slug]?slug=%5Bslug%5D.json',
'x-now-route-matches': '1=second&nextParamslug=second', 'x-now-route-matches': '1=second&nxtPslug=second',
}, },
}) })
const $3 = cheerio.load(html3) const $3 = cheerio.load(html3)
...@@ -393,7 +393,7 @@ describe('should set-up next', () => { ...@@ -393,7 +393,7 @@ describe('should set-up next', () => {
it('should return data correctly with x-matched-path', async () => { it('should return data correctly with x-matched-path', async () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
appPort, appPort,
`/_next/data/${next.buildId}/en/dynamic/first.json?nextParamslug=first`, `/_next/data/${next.buildId}/en/dynamic/first.json?nxtPslug=first`,
undefined, undefined,
{ {
headers: { headers: {
...@@ -451,7 +451,7 @@ describe('should set-up next', () => { ...@@ -451,7 +451,7 @@ describe('should set-up next', () => {
{ {
headers: { headers: {
'x-matched-path': '/catch-all/[[...rest]]', 'x-matched-path': '/catch-all/[[...rest]]',
'x-now-route-matches': '1=hello&nextParamcatchAll=hello', 'x-now-route-matches': '1=hello&nxtPcatchAll=hello',
}, },
} }
) )
...@@ -470,7 +470,7 @@ describe('should set-up next', () => { ...@@ -470,7 +470,7 @@ describe('should set-up next', () => {
{ {
headers: { headers: {
'x-matched-path': '/catch-all/[[...rest]]', 'x-matched-path': '/catch-all/[[...rest]]',
'x-now-route-matches': '1=hello/world&nextParamcatchAll=hello/world', 'x-now-route-matches': '1=hello/world&nxtPcatchAll=hello/world',
}, },
} }
) )
...@@ -507,7 +507,7 @@ describe('should set-up next', () => { ...@@ -507,7 +507,7 @@ describe('should set-up next', () => {
{ {
headers: { headers: {
'x-matched-path': `/_next/data/${next.buildId}/en/catch-all/[[...rest]].json`, 'x-matched-path': `/_next/data/${next.buildId}/en/catch-all/[[...rest]].json`,
'x-now-route-matches': '1=hello&nextParamrest=hello', 'x-now-route-matches': '1=hello&nxtPrest=hello',
}, },
} }
) )
...@@ -524,7 +524,7 @@ describe('should set-up next', () => { ...@@ -524,7 +524,7 @@ describe('should set-up next', () => {
{ {
headers: { headers: {
'x-matched-path': `/_next/data/${next.buildId}/en/catch-all/[[...rest]].json`, 'x-matched-path': `/_next/data/${next.buildId}/en/catch-all/[[...rest]].json`,
'x-now-route-matches': '1=hello/world&nextParamrest=hello/world', 'x-now-route-matches': '1=hello/world&nxtPrest=hello/world',
}, },
} }
) )
...@@ -640,7 +640,7 @@ describe('should set-up next', () => { ...@@ -640,7 +640,7 @@ describe('should set-up next', () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
appPort, appPort,
'/optional-ssp', '/optional-ssp',
{ nextParamrest: '', another: 'value' }, { nxtPrest: '', another: 'value' },
{ {
headers: { headers: {
'x-matched-path': '/optional-ssp/[[...rest]]', 'x-matched-path': '/optional-ssp/[[...rest]]',
...@@ -683,7 +683,7 @@ describe('should set-up next', () => { ...@@ -683,7 +683,7 @@ describe('should set-up next', () => {
headers: { headers: {
'x-matched-path': '/en/[slug]/social/[[...rest]]', 'x-matched-path': '/en/[slug]/social/[[...rest]]',
'x-now-route-matches': 'x-now-route-matches':
'nextLocale=en&1=en&2=user-123&nextParamslug=user-123', 'nextLocale=en&1=en&2=user-123&nxtPslug=user-123',
}, },
} }
) )
...@@ -706,7 +706,7 @@ describe('should set-up next', () => { ...@@ -706,7 +706,7 @@ describe('should set-up next', () => {
headers: { headers: {
'x-matched-path': '/optional-ssg/[[...rest]]', 'x-matched-path': '/optional-ssg/[[...rest]]',
'x-now-route-matches': 'x-now-route-matches':
'1=en%2Fes%2Fhello%252Fworld&nextParamrest=en%2Fes%2Fhello%252Fworld', '1=en%2Fes%2Fhello%252Fworld&nxtPrest=en%2Fes%2Fhello%252Fworld',
}, },
} }
) )
...@@ -723,7 +723,7 @@ describe('should set-up next', () => { ...@@ -723,7 +723,7 @@ describe('should set-up next', () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
appPort, appPort,
'/api/optional', '/api/optional',
{ nextParamrest: '', another: 'value' }, { nxtPrest: '', another: 'value' },
{ {
headers: { headers: {
'x-matched-path': '/api/optional/[[...rest]]', 'x-matched-path': '/api/optional/[[...rest]]',
...@@ -766,8 +766,7 @@ describe('should set-up next', () => { ...@@ -766,8 +766,7 @@ describe('should set-up next', () => {
const res = await fetchViaHTTP(appPort, '/en/fallback/[slug]', undefined, { const res = await fetchViaHTTP(appPort, '/en/fallback/[slug]', undefined, {
headers: { headers: {
'x-matched-path': '/en/fallback/[slug]', 'x-matched-path': '/en/fallback/[slug]',
'x-now-route-matches': 'x-now-route-matches': '2=another&nxtPslug=another&1=en&nextLocale=en',
'2=another&nextParamslug=another&1=en&nextLocale=en',
}, },
redirect: 'manual', redirect: 'manual',
}) })
...@@ -785,8 +784,7 @@ describe('should set-up next', () => { ...@@ -785,8 +784,7 @@ describe('should set-up next', () => {
const res = await fetchViaHTTP(appPort, '/fr/fallback/[slug]', undefined, { const res = await fetchViaHTTP(appPort, '/fr/fallback/[slug]', undefined, {
headers: { headers: {
'x-matched-path': '/fr/fallback/[slug]', 'x-matched-path': '/fr/fallback/[slug]',
'x-now-route-matches': 'x-now-route-matches': '2=another&nxtPslug=another&1=fr&nextLocale=fr',
'2=another&nextParamslug=another&1=fr&nextLocale=fr',
}, },
redirect: 'manual', redirect: 'manual',
}) })
......
...@@ -570,7 +570,7 @@ describe('should set-up next', () => { ...@@ -570,7 +570,7 @@ describe('should set-up next', () => {
it('should render dynamic SSR page correctly with x-matched-path', async () => { it('should render dynamic SSR page correctly with x-matched-path', async () => {
const html = await renderViaHTTP( const html = await renderViaHTTP(
appPort, appPort,
'/some-other-path?nextParamslug=first', '/some-other-path?nxtPslug=first',
undefined, undefined,
{ {
headers: { headers: {
...@@ -587,7 +587,7 @@ describe('should set-up next', () => { ...@@ -587,7 +587,7 @@ describe('should set-up next', () => {
const html2 = await renderViaHTTP( const html2 = await renderViaHTTP(
appPort, appPort,
'/some-other-path?nextParamslug=second', '/some-other-path?nxtPslug=second',
undefined, undefined,
{ {
headers: { headers: {
...@@ -606,7 +606,7 @@ describe('should set-up next', () => { ...@@ -606,7 +606,7 @@ describe('should set-up next', () => {
const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, { const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, {
headers: { headers: {
'x-matched-path': '/dynamic/[slug]', 'x-matched-path': '/dynamic/[slug]',
'x-now-route-matches': '1=second&nextParamslug=second', 'x-now-route-matches': '1=second&nxtPslug=second',
}, },
}) })
const $3 = cheerio.load(html3) const $3 = cheerio.load(html3)
...@@ -703,7 +703,7 @@ describe('should set-up next', () => { ...@@ -703,7 +703,7 @@ describe('should set-up next', () => {
it('should return data correctly with x-matched-path', async () => { it('should return data correctly with x-matched-path', async () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
appPort, appPort,
`/_next/data/${next.buildId}/dynamic/first.json?nextParamslug=first`, `/_next/data/${next.buildId}/dynamic/first.json?nxtPslug=first`,
undefined, undefined,
{ {
headers: { headers: {
...@@ -761,7 +761,7 @@ describe('should set-up next', () => { ...@@ -761,7 +761,7 @@ describe('should set-up next', () => {
{ {
headers: { headers: {
'x-matched-path': '/catch-all/[[...rest]]', 'x-matched-path': '/catch-all/[[...rest]]',
'x-now-route-matches': '1=hello&nextParamcatchAll=hello', 'x-now-route-matches': '1=hello&nxtPcatchAll=hello',
}, },
} }
) )
...@@ -780,7 +780,7 @@ describe('should set-up next', () => { ...@@ -780,7 +780,7 @@ describe('should set-up next', () => {
{ {
headers: { headers: {
'x-matched-path': '/catch-all/[[...rest]]', 'x-matched-path': '/catch-all/[[...rest]]',
'x-now-route-matches': '1=hello/world&nextParamcatchAll=hello/world', 'x-now-route-matches': '1=hello/world&nxtPcatchAll=hello/world',
}, },
} }
) )
...@@ -818,7 +818,7 @@ describe('should set-up next', () => { ...@@ -818,7 +818,7 @@ describe('should set-up next', () => {
{ {
headers: { headers: {
'x-matched-path': `/_next/data/${next.buildId}/catch-all/[[...rest]].json`, 'x-matched-path': `/_next/data/${next.buildId}/catch-all/[[...rest]].json`,
'x-now-route-matches': '1=hello&nextParamrest=hello', 'x-now-route-matches': '1=hello&nxtPrest=hello',
}, },
} }
) )
...@@ -835,7 +835,7 @@ describe('should set-up next', () => { ...@@ -835,7 +835,7 @@ describe('should set-up next', () => {
{ {
headers: { headers: {
'x-matched-path': `/_next/data/${next.buildId}/catch-all/[[...rest]].json`, 'x-matched-path': `/_next/data/${next.buildId}/catch-all/[[...rest]].json`,
'x-now-route-matches': '1=hello/world&nextParamrest=hello/world', 'x-now-route-matches': '1=hello/world&nxtPrest=hello/world',
}, },
} }
) )
...@@ -1111,7 +1111,7 @@ describe('should set-up next', () => { ...@@ -1111,7 +1111,7 @@ describe('should set-up next', () => {
headers: { headers: {
'x-matched-path': '/optional-ssg/[[...rest]]', 'x-matched-path': '/optional-ssg/[[...rest]]',
'x-now-route-matches': 'x-now-route-matches':
'1=en%2Fes%2Fhello%252Fworld&nextParamrest=en%2Fes%2Fhello%252Fworld', '1=en%2Fes%2Fhello%252Fworld&nxtPrest=en%2Fes%2Fhello%252Fworld',
}, },
} }
) )
...@@ -1145,7 +1145,7 @@ describe('should set-up next', () => { ...@@ -1145,7 +1145,7 @@ describe('should set-up next', () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
appPort, appPort,
'/api/optional/index', '/api/optional/index',
{ nextParamrest: 'index', another: 'value' }, { nxtPrest: 'index', another: 'value' },
{ {
headers: { headers: {
'x-matched-path': '/api/optional/[[...rest]]', 'x-matched-path': '/api/optional/[[...rest]]',
......
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