From 0608f9c286fc566b38dda52da3bbeb50f8a00ed2 Mon Sep 17 00:00:00 2001 From: ayoayco Date: Thu, 15 Aug 2024 17:22:19 +0200 Subject: [PATCH] feat: add pages without ending slash for caching --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ed6736d..cc3fe0e 100644 --- a/index.js +++ b/index.js @@ -92,6 +92,11 @@ export default function serviceWorker(config) { ?? []; const _pages = pages + .map(({pathname}) => pathname) + .filter(pathname => pathname !== '') + ?? []; + + const _pagesWithoutEndSlash = pages .map(({pathname}) => { const lastChar = pathname.slice(-1); const len = pathname.length; @@ -102,7 +107,7 @@ export default function serviceWorker(config) { .filter(pathname => pathname !== '') ?? []; - assets = [...new Set([...assets, ..._routes, ..._pages])] + assets = [...new Set([...assets, ..._routes, ..._pages, ..._pagesWithoutEndSlash])] try { console.log('[astro-sw] Using service worker:', swPath);