Skip to content

Commit

Permalink
[next] Fix next data route replacing (#12782)
Browse files Browse the repository at this point in the history
This fixes our route generation from replacing assuming the dot isn't
escaped which changed in vercel/next.js#73850

Re-enables test disabled in
https://linear.app/vercel/issue/ZERO-3045/unskip-failing-nextjs-test
  • Loading branch information
ijjk authored Dec 19, 2024
1 parent 976754a commit 6150fbe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-flowers-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vercel/next': patch
---

Fix next data route replacing
2 changes: 1 addition & 1 deletion packages/next/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ export const build: BuildV2 = async buildOptions => {

// ensure root-most index data route doesn't end in index.json
if (dataRoute.page === '/') {
route.src = route.src.replace(/\/index\.json/, '.json');
route.src = route.src.replace(/\/index(\\)?\.json/, '.json');
}

// make sure to route to the correct prerender output
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ export async function serverBuild({
// filter to only static data routes as dynamic routes will be handled
// below
const { pathname } = new URL(route.dest || '/', 'http://n');
return !isDynamicRoute(pathname.replace(/\.json$/, ''));
return !isDynamicRoute(pathname.replace(/(\\)?\.json$/, ''));
})
: []),

Expand Down
4 changes: 1 addition & 3 deletions packages/next/test/fixtures/00-i18n-gssp/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ const path = require('path');
const { deployAndTest } = require('../../utils');

describe(`${__dirname.split(path.sep).pop()}`, () => {
// https://linear.app/vercel/issue/ZERO-3045/unskip-failing-nextjs-test
// eslint-disable-next-line jest/no-disabled-tests
it.skip('should deploy and pass probe checks', async () => {
it('should deploy and pass probe checks', async () => {
await deployAndTest(__dirname);
});
});

0 comments on commit 6150fbe

Please sign in to comment.