From a433b9be6a3a73b300c21e28f57296471b0ced66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Dur=C3=A3o?= Date: Mon, 3 Feb 2020 03:07:45 +0000 Subject: [PATCH] Fix bug in catch-all routes with SSG (#10379) * Fix bug in catch-all routes with SSG * fix slash Co-authored-by: Joe Haddad --- packages/next/build/utils.ts | 8 +++----- test/integration/prerender/test/index.test.js | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 2bb641ed5c7e..3c68b3d54859 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -592,11 +592,9 @@ export async function isPageStatic( builtPage = builtPage.replace( `[${repeat ? '...' : ''}${validParamKey}]`, - encodeURIComponent( - repeat - ? (paramValue as string[]).join('/') - : (paramValue as string) - ) + repeat + ? (paramValue as string[]).map(encodeURIComponent).join('/') + : encodeURIComponent(paramValue as string) ) }) diff --git a/test/integration/prerender/test/index.test.js b/test/integration/prerender/test/index.test.js index a6ff7e056ba6..a6a6fc5ec63e 100644 --- a/test/integration/prerender/test/index.test.js +++ b/test/integration/prerender/test/index.test.js @@ -109,8 +109,8 @@ const expectedManifestRoutes = () => ({ initialRevalidateSeconds: false, srcRoute: null, }, - '/catchall/another%2Fvalue': { - dataRoute: `/_next/data/${buildId}/catchall/another%2Fvalue.json`, + '/catchall/another/value': { + dataRoute: `/_next/data/${buildId}/catchall/another/value.json`, initialRevalidateSeconds: 1, srcRoute: '/catchall/[...slug]', },