Skip to content

Commit 04e74a7

Browse files
author
pooya parsa
committed
fix: relax pages regex for workbox 4 compatiblity
1 parent 9167013 commit 04e74a7

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

docs/modules/workbox.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Default: `/_nuxt/(?!.*(__webpack_hmr|hot-update))`
141141

142142
Default is auto generated based on `router.base`.
143143

144-
Default: `^/(?!.*(__webpack_hmr|hot-update))`
144+
Default: `/(?!.*(__webpack_hmr|hot-update))`
145145

146146
<!-- SW -->
147147

packages/workbox/lib/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function getOptions (moduleOptions) {
5353

5454
// Optionally cache other routes for offline
5555
if (!options.pagesURLPattern) {
56-
options.pagesURLPattern = joinUrl(`^${options.routerBase}`, HMRRegex)
56+
options.pagesURLPattern = joinUrl(options.routerBase, HMRRegex)
5757
}
5858
if (options.offline && !options.offlinePage) {
5959
options.runtimeCaching.push({

test/__snapshots__/pwa.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ workbox.routing.registerRoute(new RegExp('https://google.com/.*'), new workbox.s
107107
workbox.routing.registerRoute(new RegExp('/_nuxt/(?!.*(__webpack_hmr|hot-update))'), new workbox.strategies.CacheFirst ({}), 'GET')
108108
109109
// Register router handler for offlinePage
110-
workbox.routing.registerRoute(new RegExp('^/(?!.*(__webpack_hmr|hot-update))'), ({event}) => {
110+
workbox.routing.registerRoute(new RegExp('/(?!.*(__webpack_hmr|hot-update))'), ({event}) => {
111111
return new workbox.strategies.NetworkOnly().handle({event})
112112
.catch(() => caches.match('/offline.html'))
113113
})

test/hmr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const regexes = {
1111
cacheFirstCDN: new RegExp(`${CSNPublicPath}/${HMRRegex}`),
1212

1313
// Regex for networkFist
14-
networkFirst: new RegExp(`^/${HMRRegex}`)
14+
networkFirst: new RegExp(`/${HMRRegex}`)
1515
}
1616

1717
const lists = {

0 commit comments

Comments
 (0)