1var ASSETS_PATH_REGEX = /.(jpg|png|gif|svg)$/; 2 3const domainWhitelist = [ 4 "https://profile-images-production.authory.com", 5 "https://profile-images-staging.authory.com", 6 "https://profile-images-development.authory.com", 7 "https://images-staging.authory.com", 8 "https://images-development.authory.com", 9 "https://images-production.authory.com" 10]; 11 12self.addEventListener("fetch", async function (event) { 13 const hostUrl = hostParser(event.request.url); 14 15 if ( 16 hostUrl !== self.location.origin && // different origin 17 event.request.url.match(ASSETS_PATH_REGEX) && // matches the configuration regex 18 !domainWhitelist.includes(hostUrl) // not whitelisted 19 ) { 20 console.log("[Service worker] Intercepting request ->", event.request.url); 21 22 var modifiedRequest = new Request(event.request, { 23 credentials: "omit" // this is what removes cookies 24 }); 25 26 modifiedRequest.headers.set("Accept-Language", "*"); 27 28 event.respondWith( 29 fetch(modifiedRequest) 30 .then(function (response) { 31 return response; 32 }) 33 .catch(function (error) { 34 console.log("[Service worker] Fetch failed:", error); 35 }) 36 ); 37 } else { 38 // Temporary: we had an improper implementation of 308 for awhile in prod, causing issues with inactive user urls. 39 // remove this after it's been out for a long time. 40 event.respondWith( 41 fetch(event.request) 42 .then(async (response) => { 43 if (response.status === 308) { 44 const cache = await caches.open("my-cache"); 45 await cache.delete(event.request.url); 46 47 // Try refetching the resource 48 return fetch(event.request, { cache: "no-store" }); 49 } 50 return response; 51 }) 52 .catch((error) => { 53 console.error("Fetch failed:", error); 54 return caches.match(event.request) || Response.error(); 55 }) 56 ); 57 } 58}); 59 60function hostParser(url) { 61 var match = url.match(/^(https?\:\/\/[^\/]*)(\/|$)/); 62 return match && match[1]; 63}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.