diff --git a/packages/next/next-server/lib/router/router.ts b/packages/next/next-server/lib/router/router.ts index 508b941e191bbad..0abdad552fbde27 100644 --- a/packages/next/next-server/lib/router/router.ts +++ b/packages/next/next-server/lib/router/router.ts @@ -666,7 +666,7 @@ export default class Router implements BaseRouter { _getStaticData = (asPath: string, _cachedData?: object): Promise => { let pathname = parse(asPath).pathname - pathname = !pathname || pathname === '/' ? '/index' : pathname + pathname = toRoute(!pathname || pathname === '/' ? '/index' : pathname) return process.env.NODE_ENV === 'production' && (_cachedData = this.sdc[pathname]) diff --git a/test/integration/prerender/pages/index.js b/test/integration/prerender/pages/index.js index 295502017aeb649..a81149f600a59f5 100644 --- a/test/integration/prerender/pages/index.js +++ b/test/integration/prerender/pages/index.js @@ -14,7 +14,7 @@ const Page = ({ world, time }) => { <>

hello {world}

time: {time} - + to another
diff --git a/test/integration/prerender/test/index.test.js b/test/integration/prerender/test/index.test.js index e71be48a58827fe..2b8f4109518075a 100644 --- a/test/integration/prerender/test/index.test.js +++ b/test/integration/prerender/test/index.test.js @@ -134,9 +134,11 @@ const navigateTest = (dev = false) => { // go to /another async function goFromHomeToAnother() { + await browser.eval('window.beforeAnother = true') await browser.elementByCss('#another').click() await browser.waitForElementByCss('#home') text = await browser.elementByCss('p').text() + expect(await browser.eval('window.beforeAnother')).toBe(true) expect(text).toMatch(/hello.*?world/) } await goFromHomeToAnother()