From a7a678774df8b5bc714361755643add5f26c183e Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 5 Feb 2020 11:40:46 -0600 Subject: [PATCH] Fix pageUrl having double slash on Windows --- packages/next/server/on-demand-entry-handler.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/next/server/on-demand-entry-handler.ts b/packages/next/server/on-demand-entry-handler.ts index a210f45ccaac1..550fd09adb3f2 100644 --- a/packages/next/server/on-demand-entry-handler.ts +++ b/packages/next/server/on-demand-entry-handler.ts @@ -285,9 +285,12 @@ export default function onDemandEntryHandler( throw pageNotFoundError(normalizedPagePath) } - let pageUrl = `${pagePath[0] !== '/' ? '/' : ''}${pagePath + let pageUrl = pagePath.replace(/\\/g, '/') + + pageUrl = `${pageUrl[0] !== '/' ? '/' : ''}${pageUrl .replace(new RegExp(`\\.+(?:${pageExtensions.join('|')})$`), '') - .replace(/\\/g, '/')}`.replace(/\/index$/, '') + .replace(/\/index$/, '')}` + pageUrl = pageUrl === '' ? '/' : pageUrl const bundleFile = `${normalizePagePath(pageUrl)}.js`