Unverified Commit 788183e8 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure only backslashes are in pages-manifest with i18n (#20376)

This ensures the pages-manifest only includes forward slashes and not backslashes when adding i18n page references, this also adds tests ensuring we don't regress on this in the i18n-support test suite. 

Fixes: https://github.com/vercel/next.js/issues/20330
parent 2a6f481c
...@@ -974,13 +974,16 @@ export default async function build( ...@@ -974,13 +974,16 @@ export default async function build(
continue continue
} }
const updatedRelativeDest = path.join( const updatedRelativeDest = path
'pages', .join(
locale + localeExt, 'pages',
// if it's the top-most index page we want it to be locale.EXT locale + localeExt,
// instead of locale/index.html // if it's the top-most index page we want it to be locale.EXT
page === '/' ? '' : relativeDestNoPages // instead of locale/index.html
) page === '/' ? '' : relativeDestNoPages
)
.replace(/\\/g, '/')
const updatedOrig = path.join( const updatedOrig = path.join(
exportOptions.outdir, exportOptions.outdir,
locale + localeExt, locale + localeExt,
......
...@@ -27,6 +27,17 @@ async function addDefaultLocaleCookie(browser) { ...@@ -27,6 +27,17 @@ async function addDefaultLocaleCookie(browser) {
} }
export function runTests(ctx) { export function runTests(ctx) {
if (!ctx.isDev) {
it('should not contain backslashes in pages-manifest', async () => {
const pagesManifestContent = await fs.readFile(
join(ctx.buildPagesDir, '../pages-manifest.json'),
'utf8'
)
expect(pagesManifestContent).not.toContain('\\')
expect(pagesManifestContent).toContain('/')
})
}
it('should resolve href correctly when dynamic route matches locale prefixed', async () => { it('should resolve href correctly when dynamic route matches locale prefixed', async () => {
const browser = await webdriver(ctx.appPort, `${ctx.basePath}/nl`) const browser = await webdriver(ctx.appPort, `${ctx.basePath}/nl`)
await browser.eval('window.beforeNav = 1') await browser.eval('window.beforeNav = 1')
......
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