@@ -14,7 +14,7 @@ const isLocalhost = Boolean(
14
14
window . location . hostname === 'localhost' ||
15
15
// [::1] is the IPv6 localhost address.
16
16
window . location . hostname === '[::1]' ||
17
- // 127.0.0.0 /8 are considered localhost for IPv4.
17
+ // 127.0.0.1 /8 is considered localhost for IPv4.
18
18
window . location . hostname . match (
19
19
/ ^ 1 2 7 (?: \. (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) ) { 3 } $ /
20
20
)
@@ -57,7 +57,7 @@ export function register(config) {
57
57
function registerValidSW ( swUrl , config ) {
58
58
navigator . serviceWorker
59
59
. register ( swUrl )
60
- . then ( ( registration ) => {
60
+ . then ( registration => {
61
61
registration . onupdatefound = ( ) => {
62
62
const installingWorker = registration . installing ;
63
63
if ( installingWorker == null ) {
@@ -93,25 +93,23 @@ function registerValidSW(swUrl, config) {
93
93
} ;
94
94
} ;
95
95
} )
96
- . catch ( ( error ) => {
96
+ . catch ( error => {
97
97
console . error ( 'Error during service worker registration:' , error ) ;
98
98
} ) ;
99
99
}
100
100
101
101
function checkValidServiceWorker ( swUrl , config ) {
102
102
// Check if the service worker can be found. If it can't reload the page.
103
- fetch ( swUrl , {
104
- headers : { 'Service-Worker' : 'script' } ,
105
- } )
106
- . then ( ( response ) => {
103
+ fetch ( swUrl )
104
+ . then ( response => {
107
105
// Ensure service worker exists, and that we really are getting a JS file.
108
106
const contentType = response . headers . get ( 'content-type' ) ;
109
107
if (
110
108
response . status === 404 ||
111
109
( contentType != null && contentType . indexOf ( 'javascript' ) === - 1 )
112
110
) {
113
111
// No service worker found. Probably a different app. Reload the page.
114
- navigator . serviceWorker . ready . then ( ( registration ) => {
112
+ navigator . serviceWorker . ready . then ( registration => {
115
113
registration . unregister ( ) . then ( ( ) => {
116
114
window . location . reload ( ) ;
117
115
} ) ;
@@ -130,7 +128,7 @@ function checkValidServiceWorker(swUrl, config) {
130
128
131
129
export function unregister ( ) {
132
130
if ( 'serviceWorker' in navigator ) {
133
- navigator . serviceWorker . ready . then ( ( registration ) => {
131
+ navigator . serviceWorker . ready . then ( registration => {
134
132
registration . unregister ( ) ;
135
133
} ) ;
136
134
}
0 commit comments