Skip to content

Commit 416aef5

Browse files
authored
fix
1 parent 42183ac commit 416aef5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/serviceWorker.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const isLocalhost = Boolean(
1414
window.location.hostname === 'localhost' ||
1515
// [::1] is the IPv6 localhost address.
1616
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.
1818
window.location.hostname.match(
1919
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
2020
)
@@ -57,7 +57,7 @@ export function register(config) {
5757
function registerValidSW(swUrl, config) {
5858
navigator.serviceWorker
5959
.register(swUrl)
60-
.then((registration) => {
60+
.then(registration => {
6161
registration.onupdatefound = () => {
6262
const installingWorker = registration.installing;
6363
if (installingWorker == null) {
@@ -93,25 +93,23 @@ function registerValidSW(swUrl, config) {
9393
};
9494
};
9595
})
96-
.catch((error) => {
96+
.catch(error => {
9797
console.error('Error during service worker registration:', error);
9898
});
9999
}
100100

101101
function checkValidServiceWorker(swUrl, config) {
102102
// 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 => {
107105
// Ensure service worker exists, and that we really are getting a JS file.
108106
const contentType = response.headers.get('content-type');
109107
if (
110108
response.status === 404 ||
111109
(contentType != null && contentType.indexOf('javascript') === -1)
112110
) {
113111
// No service worker found. Probably a different app. Reload the page.
114-
navigator.serviceWorker.ready.then((registration) => {
112+
navigator.serviceWorker.ready.then(registration => {
115113
registration.unregister().then(() => {
116114
window.location.reload();
117115
});
@@ -130,7 +128,7 @@ function checkValidServiceWorker(swUrl, config) {
130128

131129
export function unregister() {
132130
if ('serviceWorker' in navigator) {
133-
navigator.serviceWorker.ready.then((registration) => {
131+
navigator.serviceWorker.ready.then(registration => {
134132
registration.unregister();
135133
});
136134
}

0 commit comments

Comments
 (0)