mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Unregister old serviceworker code (#1304)
Bring back 1b9e8771ec
with a check for the prefetch serviceworker + if it is supported by the browser
This commit is contained in:
parent
9e9382936c
commit
01fa65d4a2
|
@ -7,6 +7,24 @@ import { loadGetInitialProps, getLocationOrigin } from '../utils'
|
||||||
import { _notifyBuildIdMismatch } from './'
|
import { _notifyBuildIdMismatch } from './'
|
||||||
import fetch from 'unfetch'
|
import fetch from 'unfetch'
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined' && typeof navigator.serviceWorker !== 'undefined') {
|
||||||
|
navigator.serviceWorker.getRegistrations()
|
||||||
|
.then(registrations => {
|
||||||
|
registrations.forEach(registration => {
|
||||||
|
if (!registration.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (registration.active.scriptURL.indexOf('_next-prefetcher.js') === -1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
console.warn(`Unregistered deprecated 'next/prefetch' ServiceWorker. See https://github.com/zeit/next.js#prefetching-pages`)
|
||||||
|
registration.unregister()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default class Router extends EventEmitter {
|
export default class Router extends EventEmitter {
|
||||||
constructor (pathname, query, { Component, ErrorComponent, err } = {}) {
|
constructor (pathname, query, { Component, ErrorComponent, err } = {}) {
|
||||||
super()
|
super()
|
||||||
|
|
Loading…
Reference in a new issue