From daffb2c2f585bb5533a5c75617e4d25f556c1da3 Mon Sep 17 00:00:00 2001 From: Ahmad Nassri Date: Sun, 14 Jan 2018 22:40:17 -0500 Subject: [PATCH 1/3] fix(dev-404-page): route to 404 fails when using plugin-remove-trailing-slashes Fixes: #3521 --- packages/gatsby/cache-dir/root.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/cache-dir/root.js b/packages/gatsby/cache-dir/root.js index c975b8834270c..b0e72ff54a8d7 100644 --- a/packages/gatsby/cache-dir/root.js +++ b/packages/gatsby/cache-dir/root.js @@ -174,7 +174,7 @@ const Root = () => pageResources, }) } else { - const dev404Page = pages.find(p => p.path === `/dev-404-page/`) + const dev404Page = pages.find(p => p.path.match(/^\/dev-404-page/)) return createElement(Route, { key: `404-page`, component: props => From c0f34c0e116345da4e33ec526bb4d33f3cf81f82 Mon Sep 17 00:00:00 2001 From: Ahmad Nassri Date: Sun, 14 Jan 2018 23:07:08 -0500 Subject: [PATCH 2/3] refactor(dev-404-page): use RegExp.test() as we don't need to return anything --- packages/gatsby/cache-dir/root.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/cache-dir/root.js b/packages/gatsby/cache-dir/root.js index b0e72ff54a8d7..441f32c0b5a7e 100644 --- a/packages/gatsby/cache-dir/root.js +++ b/packages/gatsby/cache-dir/root.js @@ -174,7 +174,7 @@ const Root = () => pageResources, }) } else { - const dev404Page = pages.find(p => p.path.match(/^\/dev-404-page/)) + const dev404Page = pages.find(p => /^\/dev-404-page/.test(p.path)) return createElement(Route, { key: `404-page`, component: props => From d977b3f7d542ba39e3bc4b9c262703595a67f313 Mon Sep 17 00:00:00 2001 From: Ahmad Nassri Date: Thu, 8 Feb 2018 18:15:12 -0500 Subject: [PATCH 3/3] 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/cache-dir/root.js b/packages/gatsby/cache-dir/root.js index 441f32c0b5a7e..7d383736d7ef0 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 }