Skip to content

Commit

Permalink
fix: exclude non-fluidd paths from service worker
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Dec 13, 2023
1 parent b9e29ed commit 7a001dd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ self.addEventListener('message', (event) => {
}
})

const swPath = self.location.pathname
const swPathIndex = swPath.lastIndexOf('/')

const baseUrl = swPathIndex >= 0
? swPath.substring(0, swPathIndex + 1)
: '/'

registerRoute(
`${import.meta.env.BASE_URL}config.json`,
new StaleWhileRevalidate({
Expand All @@ -33,7 +40,7 @@ precacheAndRoute(self.__WB_MANIFEST)

cleanupOutdatedCaches()

const escapedBaseUrl = escapeRegExp(import.meta.env.BASE_URL)
const escapedBaseUrl = escapeRegExp(baseUrl)

const denylist = import.meta.env.DEV
? undefined
Expand Down

0 comments on commit 7a001dd

Please sign in to comment.