From da572cad8938922ce2a1482b337f4725cb8f4afa Mon Sep 17 00:00:00 2001 From: Ahmad Nassri Date: Thu, 8 Feb 2018 19:25:26 -0400 Subject: [PATCH] fix(dev-404-page): route to 404 fails when using plugin-remove-trailing-slashes (#3522) * fix(dev-404-page): route to 404 fails when using plugin-remove-trailing-slashes Fixes: #3521 * refactor(dev-404-page): use RegExp.test() as we don't need to return anything * fix(dev-404-page): route to 404 fails when using plugin-remove-trailing-slashes updating other occurrence of 404 page check as well --- packages/gatsby/cache-dir/root.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/cache-dir/root.js b/packages/gatsby/cache-dir/root.js index 633d5cfc650b3..9f12c47fefa55 100644 --- a/packages/gatsby/cache-dir/root.js +++ b/packages/gatsby/cache-dir/root.js @@ -111,7 +111,7 @@ function shouldUpdateScroll(prevRouterProps, { location: { pathname } }) { let noMatch for (let i = 0; i < pages.length; i++) { - if (pages[i].path === `/dev-404-page/`) { + if (/^\/dev-404-page/.test(pages[i].path)) { noMatch = pages[i] break } @@ -174,7 +174,7 @@ const Root = () => pageResources, }) } else { - const dev404Page = pages.find(p => p.path === `/dev-404-page/`) + const dev404Page = pages.find(p => /^\/dev-404-page/.test(p.path)) return createElement(Route, { key: `404-page`, component: props =>