Avoid PWA caching browser extensions.

such as: Chrome extension
This commit is contained in:
Cotes Chung 2020-11-16 02:16:14 +08:00
parent d7f351b143
commit c7241ba611
1 changed files with 3 additions and 1 deletions

4
sw.js
View File

@ -13,8 +13,10 @@ var cacheName = 'chirpy-{{ "now" | date: "%Y%m%d.%H%M" }}';
function isExcluded(url) {
const regex = /(^http(s)?|^\/)/; /* the regex for CORS url or relative url */
for (const rule of exclude) {
if (url.indexOf(rule) != -1) {
if (!regex.test(url) ||
url.indexOf(rule) != -1) {
return true;
}
}