Skip to content

Commit 4a053c4

Browse files
authored
fix: reloading a page with hash fragment doesnt err (#860)
* fix: do not pass hash and query to vfetch Fixes #859 * chore: jsdoc comment lint fix
1 parent 96fd623 commit 4a053c4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/sw.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ async function fetchHandler ({ path, request, event }: FetchHandlerArg): Promise
564564
}
565565
/**
566566
* abort the signal after the configured timeout.
567+
*
568+
* @see https://github.com/ipfs/service-worker-gateway/issues/674
567569
*/
568570
const signalAbortTimeout = setTimeout(() => {
569571
abortFn({ type: 'gateway-timeout' })
@@ -572,11 +574,12 @@ async function fetchHandler ({ path, request, event }: FetchHandlerArg): Promise
572574
event.request.signal.addEventListener('abort', abortFn)
573575

574576
try {
575-
/**
576-
* @see https://github.com/ipfs/service-worker-gateway/issues/674
577-
*/
577+
const url = new URL(event.request.url)
578+
// remove the query params and hash fragment as verified-fetch/ipfs don't care about them
579+
url.search = ''
580+
url.hash = ''
578581

579-
const response = await verifiedFetch(event.request.url, {
582+
const response = await verifiedFetch(url.href, {
580583
signal,
581584
headers,
582585
redirect: 'manual',

0 commit comments

Comments
 (0)