summaryrefslogtreecommitdiff
path: root/packages/integrations/prefetch/src
diff options
context:
space:
mode:
authorGravatar Oskar Baumann <62597223+panwauu@users.noreply.github.com> 2022-10-07 16:13:51 +0200
committerGravatar GitHub <noreply@github.com> 2022-10-07 10:13:51 -0400
commit92b27e9c9253cea3d00f1f81223de19ff75c2c74 (patch)
treed0012f6888379759144637aa48b1c0632c6f88c9 /packages/integrations/prefetch/src
parent358ffb541d53911d3996eca6317748d1f4a7da3e (diff)
downloadastro-92b27e9c9253cea3d00f1f81223de19ff75c2c74.tar.gz
astro-92b27e9c9253cea3d00f1f81223de19ff75c2c74.tar.zst
astro-92b27e9c9253cea3d00f1f81223de19ff75c2c74.zip
[@astrojs/prefetch]: Prevent prefetching current page (#5009)
* Check that removal of url.hash breaks no tests * test if status-quo is as expected * Adapt tests to fail * Adapt the shouldPreload function to skip same path * Add changeset
Diffstat (limited to 'packages/integrations/prefetch/src')
-rw-r--r--packages/integrations/prefetch/src/client.ts2
1 files changed, 1 insertions, 1 deletions
diff --git a/packages/integrations/prefetch/src/client.ts b/packages/integrations/prefetch/src/client.ts
index 50df858cb..0b37946ee 100644
--- a/packages/integrations/prefetch/src/client.ts
+++ b/packages/integrations/prefetch/src/client.ts
@@ -11,7 +11,7 @@ function shouldPreload({ href }: { href: string }) {
const url = new URL(href);
return (
window.location.origin === url.origin &&
- window.location.pathname !== url.hash &&
+ window.location.pathname !== url.pathname &&
!preloaded.has(href)
);
} catch {}