One Calendar is a privacy-first calendar web app built with Next.js. It has modern security features, including e2ee, password-protected sharing, and self-destructing share links ๐Ÿ“… calendar.xyehr.cn
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: cache only whitelisted app shell paths in service worker

+17 -1
+17 -1
public/sw.js
··· 1 - const CACHE_NAME = "one-calendar-shell-v2"; 1 + const CACHE_NAME = "one-calendar-shell-v3"; 2 2 const OFFLINE_URLS = ["/app", "/icon.svg"]; 3 + const STATIC_PATH_PREFIXES = ["/_next/static/", "/_next/image/", "/icons/"]; 4 + const STATIC_FILE_PATTERN = 5 + /\.(?:js|css|png|jpg|jpeg|gif|svg|webp|ico|woff|woff2|ttf|otf|eot|json|txt|xml|webmanifest)$/i; 6 + 7 + function shouldCacheRequest(requestUrl) { 8 + if (requestUrl.origin !== self.location.origin) return false; 9 + if (OFFLINE_URLS.includes(requestUrl.pathname)) return true; 10 + if (STATIC_PATH_PREFIXES.some((prefix) => requestUrl.pathname.startsWith(prefix))) { 11 + return true; 12 + } 13 + return STATIC_FILE_PATTERN.test(requestUrl.pathname); 14 + } 3 15 4 16 self.addEventListener("install", (event) => { 5 17 event.waitUntil( ··· 32 44 return; 33 45 } 34 46 if (requestUrl.pathname.startsWith("/api/")) { 47 + event.respondWith(fetch(event.request)); 48 + return; 49 + } 50 + if (!shouldCacheRequest(requestUrl)) { 35 51 event.respondWith(fetch(event.request)); 36 52 return; 37 53 }