Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Fix: don't treat direct requests for non-form HTML URLs as form requests
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelidlessness committed Nov 14, 2022
1 parent a1f6b7a commit 1c39cec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions public/js/src/module/offline-app-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ const onFetch = async (request) => {
return fetch(request, FETCH_OPTIONS);
}

const { pathname } = new URL(url);
const isFormPageRequest =
url.includes('/x/') && (referrer === '' || referrer === url);
/\/x\/[^/]+\/?$/.test(pathname) &&
(referrer === '' || referrer === url);

/**
* A response for the form page initial HTML is always cached with the
Expand Down Expand Up @@ -130,7 +132,10 @@ const onFetch = async (request) => {
return caches.match(cacheKey);
}

await cacheResponse(url, new Response(null, { status: 204 }));
await cacheResponse(
url,
new Response(null, { status: 204, statusText: 'No Content' })
);
}

const isServiceWorkerScript = url === self.location.href;
Expand Down

0 comments on commit 1c39cec

Please sign in to comment.