From c7241ba61180fd5abc8650b242bea52b18e1b136 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Mon, 16 Nov 2020 02:16:14 +0800 Subject: [PATCH] Avoid PWA caching browser extensions. such as: Chrome extension --- sw.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sw.js b/sw.js index 91329e3..542852e 100644 --- a/sw.js +++ b/sw.js @@ -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; } }