From 124b963d097cde718363ce4de4772d988a44dc5e Mon Sep 17 00:00:00 2001 From: nellaparedes Date: Sat, 10 Jul 2021 00:09:30 -0500 Subject: [PATCH 1/7] Prevent stripping url params on navigate when sw update --- packages/gatsby/cache-dir/navigation.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/cache-dir/navigation.js b/packages/gatsby/cache-dir/navigation.js index e5f5d2389b25c..cee7eaef24368 100644 --- a/packages/gatsby/cache-dir/navigation.js +++ b/packages/gatsby/cache-dir/navigation.js @@ -47,7 +47,8 @@ const navigate = (to, options = {}) => { return } - let { pathname } = parsePath(to) + let { pathname, search } = parsePath(to) + const redirect = maybeGetBrowserRedirect(pathname) // If we're redirecting, just replace the passed in pathname @@ -60,7 +61,7 @@ const navigate = (to, options = {}) => { // If we had a service worker update, no matter the path, reload window and // reset the pathname whitelist if (window.___swUpdated) { - window.location = pathname + window.location = pathname + search return } From 6d391a5511f2ae370c3dba60aa6d33e88e5d5cbb Mon Sep 17 00:00:00 2001 From: David E Disch Date: Sat, 10 Jul 2021 15:13:49 +1000 Subject: [PATCH 2/7] Update navigation.js --- packages/gatsby/cache-dir/navigation.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/gatsby/cache-dir/navigation.js b/packages/gatsby/cache-dir/navigation.js index cee7eaef24368..bf4666bcdcf44 100644 --- a/packages/gatsby/cache-dir/navigation.js +++ b/packages/gatsby/cache-dir/navigation.js @@ -48,7 +48,6 @@ const navigate = (to, options = {}) => { } let { pathname, search } = parsePath(to) - const redirect = maybeGetBrowserRedirect(pathname) // If we're redirecting, just replace the passed in pathname From f5dab8b7dbdfb810df134c2d45f9e2bcabd71d2c Mon Sep 17 00:00:00 2001 From: Fraser Solomon <35257108+fraserisland@users.noreply.github.com> Date: Sat, 10 Jul 2021 15:20:29 +1000 Subject: [PATCH 3/7] Append search params to redirect --- packages/gatsby/cache-dir/navigation.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/gatsby/cache-dir/navigation.js b/packages/gatsby/cache-dir/navigation.js index bf4666bcdcf44..32c3546626ed1 100644 --- a/packages/gatsby/cache-dir/navigation.js +++ b/packages/gatsby/cache-dir/navigation.js @@ -54,7 +54,10 @@ const navigate = (to, options = {}) => { // to the one we want to redirect to. if (redirect) { to = redirect.toPath - pathname = parsePath(to).pathname + const path = parsePath(to) + + pathname = path.pathname + search = path.search } // If we had a service worker update, no matter the path, reload window and From ce89ac09787a7eb9cf343e14c3e9e20a3c714a17 Mon Sep 17 00:00:00 2001 From: Fraser Solomon <35257108+fraserisland@users.noreply.github.com> Date: Sat, 10 Jul 2021 15:22:14 +1000 Subject: [PATCH 4/7] path -> parsedPath --- packages/gatsby/cache-dir/navigation.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/gatsby/cache-dir/navigation.js b/packages/gatsby/cache-dir/navigation.js index 32c3546626ed1..69a073f2d3d09 100644 --- a/packages/gatsby/cache-dir/navigation.js +++ b/packages/gatsby/cache-dir/navigation.js @@ -54,10 +54,10 @@ const navigate = (to, options = {}) => { // to the one we want to redirect to. if (redirect) { to = redirect.toPath - const path = parsePath(to) + const parsedPath = parsePath(to) - pathname = path.pathname - search = path.search + pathname = parsedPath.pathname + search = parsedPath.search } // If we had a service worker update, no matter the path, reload window and From 10dc1df00bfa9daa1bec6342cf436a60dd420c08 Mon Sep 17 00:00:00 2001 From: nellaparedes Date: Sat, 10 Jul 2021 12:07:47 -0500 Subject: [PATCH 5/7] remove exrta spaces --- packages/gatsby/cache-dir/navigation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/cache-dir/navigation.js b/packages/gatsby/cache-dir/navigation.js index 69a073f2d3d09..1255b40a5e892 100644 --- a/packages/gatsby/cache-dir/navigation.js +++ b/packages/gatsby/cache-dir/navigation.js @@ -55,7 +55,7 @@ const navigate = (to, options = {}) => { if (redirect) { to = redirect.toPath const parsedPath = parsePath(to) - + pathname = parsedPath.pathname search = parsedPath.search } From f3d47d65369bf1c5f00479a82502252f5af53bc9 Mon Sep 17 00:00:00 2001 From: David E Disch Date: Sun, 11 Jul 2021 21:56:19 +1000 Subject: [PATCH 6/7] Update navigation.js --- packages/gatsby/cache-dir/navigation.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/cache-dir/navigation.js b/packages/gatsby/cache-dir/navigation.js index 1255b40a5e892..c1af3c877d7e4 100644 --- a/packages/gatsby/cache-dir/navigation.js +++ b/packages/gatsby/cache-dir/navigation.js @@ -47,7 +47,7 @@ const navigate = (to, options = {}) => { return } - let { pathname, search } = parsePath(to) + let { pathname, search, hash } = parsePath(to) const redirect = maybeGetBrowserRedirect(pathname) // If we're redirecting, just replace the passed in pathname @@ -58,12 +58,13 @@ const navigate = (to, options = {}) => { pathname = parsedPath.pathname search = parsedPath.search + hash = parsedPath.hash } // If we had a service worker update, no matter the path, reload window and // reset the pathname whitelist if (window.___swUpdated) { - window.location = pathname + search + window.location = pathname + search + hash return } From 734b48228f43ece104e02b502b3d5e6197be2670 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Mon, 12 Jul 2021 13:40:24 +0200 Subject: [PATCH 7/7] revert some changes that are not strictly necessary for this PR --- packages/gatsby/cache-dir/navigation.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/gatsby/cache-dir/navigation.js b/packages/gatsby/cache-dir/navigation.js index c1af3c877d7e4..5260778d14e8a 100644 --- a/packages/gatsby/cache-dir/navigation.js +++ b/packages/gatsby/cache-dir/navigation.js @@ -54,11 +54,7 @@ const navigate = (to, options = {}) => { // to the one we want to redirect to. if (redirect) { to = redirect.toPath - const parsedPath = parsePath(to) - - pathname = parsedPath.pathname - search = parsedPath.search - hash = parsedPath.hash + pathname = parsePath(to).pathname } // If we had a service worker update, no matter the path, reload window and