From c120fd82f9dbc38a3225254f29ab6b232ecf89a0 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 20 Oct 2020 12:58:18 -0500 Subject: [PATCH] [next] Ensure root-most index GSP page is located correctly (#5309) --- packages/now-next/src/index.ts | 1 + packages/now-next/src/utils.ts | 4 +++- .../test/fixtures/00-i18n-support/pages/index.js | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/now-next/src/index.ts b/packages/now-next/src/index.ts index eceba1dfae1..6b7e73e91ff 100644 --- a/packages/now-next/src/index.ts +++ b/packages/now-next/src/index.ts @@ -1651,6 +1651,7 @@ export const build = async ({ // if there isn't a srcRoute then it's a non-dynamic SSG page and if (nonDynamicSsg || isFallback) { routeFileNoExt = addLocaleOrDefault( + // root index files are located without folder/index.html routeFileNoExt, routesManifest, locale diff --git a/packages/now-next/src/utils.ts b/packages/now-next/src/utils.ts index b68f37a3971..e19f86753ef 100644 --- a/packages/now-next/src/utils.ts +++ b/packages/now-next/src/utils.ts @@ -1110,7 +1110,9 @@ export function addLocaleOrDefault( if (!routesManifest?.i18n) return pathname; if (!locale) locale = routesManifest.i18n.defaultLocale; - return locale ? `/${locale}${pathname}` : pathname; + return locale + ? `/${locale}${pathname === '/index' ? '' : pathname}` + : pathname; } export { diff --git a/packages/now-next/test/fixtures/00-i18n-support/pages/index.js b/packages/now-next/test/fixtures/00-i18n-support/pages/index.js index 1467602e631..24f4489b20a 100644 --- a/packages/now-next/test/fixtures/00-i18n-support/pages/index.js +++ b/packages/now-next/test/fixtures/00-i18n-support/pages/index.js @@ -44,3 +44,12 @@ export default function Page(props) { ); } + +export const getStaticProps = ({ locale, locales }) => { + return { + props: { + locale, + locales, + }, + }; +};