Bypass event.respondWith for some paths (#12953)
This commit is contained in:
parent
0460f96347
commit
e6a2df73bf
1 changed files with 13 additions and 3 deletions
|
|
@ -35,10 +35,20 @@
|
|||
self.clients.claim();
|
||||
});
|
||||
|
||||
function includesUnsupportedPath(url) {
|
||||
return [
|
||||
'/%F0%9F%92%B8', // 💸 (hiring)
|
||||
'/admin', // Don't run on admin dashboard.
|
||||
'/oauth/', // Skip oauth apps
|
||||
'/onboarding', // Don't run on onboarding.
|
||||
'/users/auth', // Don't run on authentication.
|
||||
].some(path => url.includes(path))
|
||||
}
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
// We only want to call event.respondWith() if this is a navigation request
|
||||
// for an HTML page.
|
||||
if (event.request.mode === "navigate") {
|
||||
// for an HTML page with a few exceptions.
|
||||
if (event.request.mode === "navigate" && !includesUnsupportedPath(event.request.url)) {
|
||||
event.respondWith(
|
||||
(async () => {
|
||||
try {
|
||||
|
|
@ -72,4 +82,4 @@
|
|||
// event.respondWith(), the request will be handled by the browser as if there
|
||||
// were no service worker involvement.
|
||||
});
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue