Skip to content

Commit 2b6e533

Browse files
committed
Fetch request origin
1 parent fce33ce commit 2b6e533

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

service-worker.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ self.addEventListener('install', event => {
55
caches.open(CACHE_NAME).then(cache => {
66
return cache.addAll([
77
'/',
8-
'/index.js',
8+
'/index.js'
99
]);
10-
}),
10+
})
1111
);
1212
});
1313

1414
self.addEventListener('fetch', event => {
15-
if (event.request.url.startsWith(self.location.origin)) {
15+
const url = new URL(event.request.url);
16+
if (url.origin === self.location.origin) {
1617
event.respondWith(
1718
caches.open(CACHE_NAME).then(cache => {
1819
return cache.match(event.request, {ignoreSearch: true}).then(response => {
@@ -22,7 +23,7 @@ self.addEventListener('fetch', event => {
2223
return response;
2324
});
2425
});
25-
}),
26+
})
2627
);
2728
}
2829
});

0 commit comments

Comments
 (0)