Skip to content

Commit

Permalink
fix: relax pages regex for workbox 4 compatiblity
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed Feb 8, 2019
1 parent 9167013 commit 04e74a7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/modules/workbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Default: `/_nuxt/(?!.*(__webpack_hmr|hot-update))`

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

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

<!-- SW -->

Expand Down
2 changes: 1 addition & 1 deletion packages/workbox/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function getOptions (moduleOptions) {

// Optionally cache other routes for offline
if (!options.pagesURLPattern) {
options.pagesURLPattern = joinUrl(`^${options.routerBase}`, HMRRegex)
options.pagesURLPattern = joinUrl(options.routerBase, HMRRegex)
}
if (options.offline && !options.offlinePage) {
options.runtimeCaching.push({
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/pwa.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ workbox.routing.registerRoute(new RegExp('https://google.com/.*'), new workbox.s
workbox.routing.registerRoute(new RegExp('/_nuxt/(?!.*(__webpack_hmr|hot-update))'), new workbox.strategies.CacheFirst ({}), 'GET')
// Register router handler for offlinePage
workbox.routing.registerRoute(new RegExp('^/(?!.*(__webpack_hmr|hot-update))'), ({event}) => {
workbox.routing.registerRoute(new RegExp('/(?!.*(__webpack_hmr|hot-update))'), ({event}) => {
return new workbox.strategies.NetworkOnly().handle({event})
.catch(() => caches.match('/offline.html'))
})
Expand Down
2 changes: 1 addition & 1 deletion test/hmr.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const regexes = {
cacheFirstCDN: new RegExp(`${CSNPublicPath}/${HMRRegex}`),

// Regex for networkFist
networkFirst: new RegExp(`^/${HMRRegex}`)
networkFirst: new RegExp(`/${HMRRegex}`)
}

const lists = {
Expand Down

0 comments on commit 04e74a7

Please sign in to comment.