Skip to content

Commit

Permalink
Merge pull request #342 from skyclouds2001/patch-1
Browse files Browse the repository at this point in the history
为 Service Worker 增加拦截请求时的筛选规则
  • Loading branch information
User782Tec authored Dec 12, 2023
2 parents 7b5305f + 5a2bc93 commit 6840d0c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ let dymanic = [
'assets.msn.cn'
]
this.addEventListener('fetch', function (event) {
if (!/^https?:$/.test(new URL(event.request.url).protocol)) return

event.respondWith(
caches.match(event.request).then(res => {
let fl = false;
Expand All @@ -21,7 +23,6 @@ this.addEventListener('fetch', function (event) {
return res ||
fetch(event.request)
.then(responese => {
// console.log(event.request);
const responeseClone = responese.clone();
caches.open('def').then(cache => {
console.log('下载数据', responeseClone.url);
Expand Down

0 comments on commit 6840d0c

Please sign in to comment.