From c85d013048c802f335db72953d1f72ce01daa18a Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 7 Oct 2022 10:14:45 +0200 Subject: [PATCH 1/5] Check that removal of url.hash breaks no tests --- packages/integrations/prefetch/src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/prefetch/src/client.ts b/packages/integrations/prefetch/src/client.ts index 50df858cbe89..e1b0fb85c853 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.hash && !preloaded.has(href) ); } catch {} From ee36f339dfc18fe7afdc27c1672b6d33fd8bd8a6 Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 7 Oct 2022 10:16:16 +0200 Subject: [PATCH 2/5] test if status-quo is as expected --- packages/integrations/prefetch/test/basic-prefetch.test.js | 2 ++ .../test/fixtures/basic-prefetch/src/pages/index.astro | 3 +++ 2 files changed, 5 insertions(+) diff --git a/packages/integrations/prefetch/test/basic-prefetch.test.js b/packages/integrations/prefetch/test/basic-prefetch.test.js index 0dbb571beebb..be0d03352854 100644 --- a/packages/integrations/prefetch/test/basic-prefetch.test.js +++ b/packages/integrations/prefetch/test/basic-prefetch.test.js @@ -34,6 +34,7 @@ test.describe('Basic prefetch', () => { '/contact was prefetched' ).toBeTruthy(); await expect(requests.has(astro.resolveUrl('/admin')), '/admin was skipped').toBeFalsy(); + await expect(requests.has(astro.resolveUrl('/')), '/ was skipped').toBeTruthy(); }); }); }); @@ -70,6 +71,7 @@ test.describe('Basic prefetch', () => { '/contact was prefetched' ).toBeTruthy(); await expect(requests.has(astro.resolveUrl('/admin')), '/admin was skipped').toBeFalsy(); + await expect(requests.has(astro.resolveUrl('/')), '/ was skipped').toBeTruthy(); }); }); }); diff --git a/packages/integrations/prefetch/test/fixtures/basic-prefetch/src/pages/index.astro b/packages/integrations/prefetch/test/fixtures/basic-prefetch/src/pages/index.astro index d2c674ebc781..58a864552515 100644 --- a/packages/integrations/prefetch/test/fixtures/basic-prefetch/src/pages/index.astro +++ b/packages/integrations/prefetch/test/fixtures/basic-prefetch/src/pages/index.astro @@ -10,6 +10,9 @@