diff --git a/packages/next/src/server/lib/router-utils/build-data-route.ts b/packages/next/src/server/lib/router-utils/build-data-route.ts index 6aab1d9144ceb..b0564da5ac1a1 100644 --- a/packages/next/src/server/lib/router-utils/build-data-route.ts +++ b/packages/next/src/server/lib/router-utils/build-data-route.ts @@ -33,7 +33,7 @@ export function buildDataRoute(page: string, buildId: string) { `^${path.posix.join( '/_next/data', escapeStringRegexp(buildId), - `${pagePath}.json` + `${pagePath}\\.json` )}$` ).source ) diff --git a/test/e2e/edge-pages-support/index.test.ts b/test/e2e/edge-pages-support/index.test.ts index 9ba79dc3b28f4..625489c236d1f 100644 --- a/test/e2e/edge-pages-support/index.test.ts +++ b/test/e2e/edge-pages-support/index.test.ts @@ -163,7 +163,7 @@ describe('edge-render-getserversideprops', () => { expect(manifest.dataRoutes).toEqual([ { dataRouteRegex: normalizeRegEx( - `^/_next/data/${escapeStringRegexp(next.buildId)}/index.json$` + `^/_next/data/${escapeStringRegexp(next.buildId)}/index\\.json$` ), page: '/', }, diff --git a/test/e2e/getserversideprops/test/index.test.ts b/test/e2e/getserversideprops/test/index.test.ts index 09c8450bd3b07..b0957855a4ae0 100644 --- a/test/e2e/getserversideprops/test/index.test.ts +++ b/test/e2e/getserversideprops/test/index.test.ts @@ -26,19 +26,19 @@ let next: NextInstance const expectedManifestRoutes = () => [ { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/index.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/index\\.json$` ), page: '/', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/another.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/another\\.json$` ), page: '/another', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/blog.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/blog\\.json$` ), page: '/blog', }, @@ -83,44 +83,44 @@ const expectedManifestRoutes = () => [ }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/custom-cache.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/custom-cache\\.json$` ), page: '/custom-cache', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/default-revalidate.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/default-revalidate\\.json$` ), page: '/default-revalidate', }, { dataRouteRegex: `^\\/_next\\/data\\/${escapeRegex( buildId - )}\\/early-request-end.json$`, + )}\\/early-request-end\\.json$`, page: '/early-request-end', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/enoent.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/enoent\\.json$` ), page: '/enoent', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/invalid-keys.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/invalid-keys\\.json$` ), page: '/invalid-keys', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/non-json.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/non-json\\.json$` ), page: '/non-json', }, { dataRouteRegex: `^\\/_next\\/data\\/${escapeRegex( buildId - )}\\/not-found.json$`, + )}\\/not-found\\.json$`, page: '/not-found', }, { @@ -137,13 +137,13 @@ const expectedManifestRoutes = () => [ }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/promise.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/promise\\.json$` ), page: '/promise', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/promise\\/mutate-res.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/promise\\/mutate-res\\.json$` ), page: '/promise/mutate-res', }, @@ -151,7 +151,7 @@ const expectedManifestRoutes = () => [ dataRouteRegex: normalizeRegEx( `^\\/_next\\/data\\/${escapeRegex( buildId - )}\\/promise\\/mutate-res-no-streaming.json$` + )}\\/promise\\/mutate-res-no-streaming\\.json$` ), page: '/promise/mutate-res-no-streaming', }, @@ -159,25 +159,25 @@ const expectedManifestRoutes = () => [ dataRouteRegex: normalizeRegEx( `^\\/_next\\/data\\/${escapeRegex( buildId - )}\\/promise\\/mutate-res-props.json$` + )}\\/promise\\/mutate-res-props\\.json$` ), page: '/promise/mutate-res-props', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/refresh.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/refresh\\.json$` ), page: '/refresh', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/slow.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/slow\\.json$` ), page: '/slow', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/something.json$` + `^\\/_next\\/data\\/${escapeRegex(buildId)}\\/something\\.json$` ), page: '/something', }, diff --git a/test/e2e/prerender.test.ts b/test/e2e/prerender.test.ts index 238742b745f3d..531f47efba330 100644 --- a/test/e2e/prerender.test.ts +++ b/test/e2e/prerender.test.ts @@ -1334,7 +1334,7 @@ describe('Prerender', () => { expect(dataRoutes).toEqual([ { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(next.buildId)}\\/index.json$` + `^\\/_next\\/data\\/${escapeRegex(next.buildId)}\\/index\\.json$` ), page: '/', }, @@ -1342,7 +1342,7 @@ describe('Prerender', () => { dataRouteRegex: normalizeRegEx( `^\\/_next\\/data\\/${escapeRegex( next.buildId - )}\\/another.json$` + )}\\/another\\.json$` ), page: '/another', }, @@ -1364,7 +1364,7 @@ describe('Prerender', () => { dataRouteRegex: normalizeRegEx( `^\\/_next\\/data\\/${escapeRegex( next.buildId - )}\\/bad-gssp.json$` + )}\\/bad-gssp\\.json$` ), page: '/bad-gssp', }, @@ -1372,7 +1372,7 @@ describe('Prerender', () => { dataRouteRegex: normalizeRegEx( `^\\/_next\\/data\\/${escapeRegex( next.buildId - )}\\/bad-ssr.json$` + )}\\/bad-ssr\\.json$` ), page: '/bad-ssr', }, @@ -1414,7 +1414,7 @@ describe('Prerender', () => { }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(next.buildId)}\\/blog.json$` + `^\\/_next\\/data\\/${escapeRegex(next.buildId)}\\/blog\\.json$` ), page: '/blog', }, @@ -1493,7 +1493,7 @@ describe('Prerender', () => { dataRouteRegex: normalizeRegEx( `^\\/_next\\/data\\/${escapeRegex( next.buildId - )}\\/default-revalidate.json$` + )}\\/default-revalidate\\.json$` ), page: '/default-revalidate', }, @@ -1530,7 +1530,7 @@ describe('Prerender', () => { // dataRouteRegex: normalizeRegEx( // `^\\/_next\\/data\\/${escapeRegex( // next.buildId - // )}\\/index\\/index.json$` + // )}\\/index\\/index\\.json$` // ), // page: '/index', // }, @@ -1551,13 +1551,13 @@ describe('Prerender', () => { { dataRouteRegex: `^\\/_next\\/data\\/${escapeRegex( next.buildId - )}\\/large-page-data.json$`, + )}\\/large-page-data\\.json$`, page: '/large-page-data', }, { dataRouteRegex: `^\\/_next\\/data\\/${escapeRegex( next.buildId - )}\\/large-page-data-ssr.json$`, + )}\\/large-page-data-ssr\\.json$`, page: '/large-page-data-ssr', }, { @@ -1592,7 +1592,7 @@ describe('Prerender', () => { dataRouteRegex: normalizeRegEx( `^\\/_next\\/data\\/${escapeRegex( next.buildId - )}\\/preview.json$` + )}\\/preview\\.json$` ), page: '/preview', }, @@ -1600,13 +1600,13 @@ describe('Prerender', () => { dataRouteRegex: normalizeRegEx( `^\\/_next\\/data\\/${escapeRegex( next.buildId - )}\\/something.json$` + )}\\/something\\.json$` ), page: '/something', }, { dataRouteRegex: normalizeRegEx( - `^\\/_next\\/data\\/${escapeRegex(next.buildId)}\\/ssr.json$` + `^\\/_next\\/data\\/${escapeRegex(next.buildId)}\\/ssr\\.json$` ), page: '/ssr', },