From ca387909eaaeac78848b79031c318da044fde5a5 Mon Sep 17 00:00:00 2001 From: RH+ Date: Fri, 7 Feb 2025 19:33:31 +0900 Subject: [PATCH] Fix: Replace /sw/check to /sw/img in service worker checkCache --- public/sw.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/public/sw.js b/public/sw.js index ed1172cb..5d4296d1 100644 --- a/public/sw.js +++ b/public/sw.js @@ -87,8 +87,19 @@ self.addEventListener('fetch', (event) => { async function checkCache(url){ const cache = await caches.open('risuCache') + const origURL = url.pathname; + + if(url.pathname.startsWith("/sw/check")) { + url.pathname = "/sw/img" + url.pathname.slice(9); + return new Response(JSON.stringify({ + "able": !!(await cache.match(url)), + "origURL": origURL, + })) + } + return new Response(JSON.stringify({ - "able": !!(await cache.match(url)) + "able": !!(await cache.match(url)), + "origURL": origURL, })) }