Skip to content

Commit

Permalink
refactor: update sw.js
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed Jul 17, 2024
1 parent 65d467f commit d0dc38d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions _javascript/pwa/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { baseurl } from '../../_config.yml';
importScripts(`${baseurl}/assets/js/data/swconf.js`);

const purge = swconf.purge;
const interceptor = swconf.interceptor;

function verifyUrl(url) {
const requestUrl = new URL(url);
Expand All @@ -12,13 +13,13 @@ function verifyUrl(url) {
return false;
}

for (const denyUrl of swconf.denyUrls) {
if (requestUrl.href.startsWith(denyUrl)) {
for (const prefix of interceptor.urlPrefixes) {
if (requestUrl.href.startsWith(prefix)) {
return false;
}
}

for (const path of swconf.denyPaths) {
for (const path of interceptor.paths) {
if (requestPath.startsWith(path)) {
return false;
}
Expand Down

0 comments on commit d0dc38d

Please sign in to comment.