diff --git a/packages/next/build/webpack/plugins/pages-manifest-plugin.js b/packages/next/build/webpack/plugins/pages-manifest-plugin.js index b7ac3550e190c..918b3b2c508d7 100644 --- a/packages/next/build/webpack/plugins/pages-manifest-plugin.js +++ b/packages/next/build/webpack/plugins/pages-manifest-plugin.js @@ -23,7 +23,8 @@ export default class PagesManifestPlugin { } const {name} = entry - pages[`/${pagePath.replace(/\\/g, '/')}`] = name + // Write filename, replace any backslashes in path (on windows) with forwardslashes for cross-platform consistency. + pages[`/${pagePath.replace(/\\/g, '/')}`] = name.replace(/\\/g, '/') } if (typeof pages['/index'] !== 'undefined') { diff --git a/test/integration/production/test/index.test.js b/test/integration/production/test/index.test.js index e5c475f0aa6d8..757a7c6053688 100644 --- a/test/integration/production/test/index.test.js +++ b/test/integration/production/test/index.test.js @@ -16,7 +16,7 @@ import fetch from 'node-fetch' import dynamicImportTests from './dynamic' import processEnv from './process-env' import security from './security' -import {BUILD_MANIFEST, REACT_LOADABLE_MANIFEST} from 'next-server/constants' +import {BUILD_MANIFEST, REACT_LOADABLE_MANIFEST, PAGES_MANIFEST} from 'next-server/constants' const appDir = join(__dirname, '../') let appPort @@ -319,6 +319,17 @@ describe('Production Usage', () => { expect(serverSideJsBody).toMatch(/404/) }) + it('should not put backslashes in pages-manifest.json', () => { + // Whatever platform you build on, pages-manifest.json should use forward slash (/) + // See: https://github.com/zeit/next.js/issues/4920 + const pagesManifest = require(join('..', '.next', 'server', PAGES_MANIFEST)) + + for (let key of Object.keys(pagesManifest)) { + expect(key).not.toMatch(/\\/) + expect(pagesManifest[key]).not.toMatch(/\\/) + } + }) + it('should handle failed param decoding', async () => { const html = await renderViaHTTP(appPort, '/%DE~%C7%1fY/') expect(html).toMatch(/400/)