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

4
sw.js
View file

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