From 5a94a2feba344029699705dd15f33891266b7b6c Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 22 Apr 2022 12:22:30 +0530 Subject: [PATCH] Move handleConfigRequest inside handleRequest --- src/platform/web/sw.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/platform/web/sw.js b/src/platform/web/sw.js index 2d43d1ee..a9a92979 100644 --- a/src/platform/web/sw.js +++ b/src/platform/web/sw.js @@ -75,11 +75,7 @@ self.addEventListener('fetch', (event) => { This has to do with xhr not being supported in service workers. */ if (event.request.method === "GET") { - if (event.request.url.includes("config.json")) { - event.respondWith(handleConfigRequest(event.request)); - } else { - event.respondWith(handleRequest(event.request)); - } + event.respondWith(handleRequest(event.request)); } }); @@ -96,8 +92,12 @@ function isCacheableThumbnail(url) { const baseURL = new URL(self.registration.scope); let pendingFetchAbortController = new AbortController(); + async function handleRequest(request) { try { + if (request.url.includes("config.json")) { + return handleConfigRequest(request); + } const url = new URL(request.url); // rewrite / to /index.html so it hits the cache if (url.origin === baseURL.origin && url.pathname === baseURL.pathname) {