forked from mystiq/hydrogen-web
Move handleConfigRequest inside handleRequest
This commit is contained in:
parent
c6691cf1cb
commit
5a94a2feba
1 changed files with 5 additions and 5 deletions
|
@ -75,12 +75,8 @@ self.addEventListener('fetch', (event) => {
|
||||||
This has to do with xhr not being supported in service workers.
|
This has to do with xhr not being supported in service workers.
|
||||||
*/
|
*/
|
||||||
if (event.request.method === "GET") {
|
if (event.request.method === "GET") {
|
||||||
if (event.request.url.includes("config.json")) {
|
|
||||||
event.respondWith(handleConfigRequest(event.request));
|
|
||||||
} else {
|
|
||||||
event.respondWith(handleRequest(event.request));
|
event.respondWith(handleRequest(event.request));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function isCacheableThumbnail(url) {
|
function isCacheableThumbnail(url) {
|
||||||
|
@ -96,8 +92,12 @@ function isCacheableThumbnail(url) {
|
||||||
|
|
||||||
const baseURL = new URL(self.registration.scope);
|
const baseURL = new URL(self.registration.scope);
|
||||||
let pendingFetchAbortController = new AbortController();
|
let pendingFetchAbortController = new AbortController();
|
||||||
|
|
||||||
async function handleRequest(request) {
|
async function handleRequest(request) {
|
||||||
try {
|
try {
|
||||||
|
if (request.url.includes("config.json")) {
|
||||||
|
return handleConfigRequest(request);
|
||||||
|
}
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
// rewrite / to /index.html so it hits the cache
|
// rewrite / to /index.html so it hits the cache
|
||||||
if (url.origin === baseURL.origin && url.pathname === baseURL.pathname) {
|
if (url.origin === baseURL.origin && url.pathname === baseURL.pathname) {
|
||||||
|
|
Loading…
Reference in a new issue