1/* eslint-env serviceworker */ 2/* eslint-disable no-restricted-globals */ 3// Braze Web Push Service Worker 4// This service worker handles push notifications from Braze 5 6self.importScripts('https://js.appboycdn.com/web-sdk/5.4/service-worker.js'); 7 8// Handle notification clicks 9self.addEventListener('notificationclick', function (event) { 10 event.notification.close(); 11 12 const { data } = event.notification; 13 if (data && data.url) { 14 const { url } = data; 15 16 // Validate URL is safe before opening 17 try { 18 const urlObj = new URL(url); 19 const allowedOrigins = [self.location.origin]; 20 21 // Only allow https URLs from our own origin 22 if (urlObj.protocol === 'https:' && allowedOrigins.includes(urlObj.origin)) { 23 event.waitUntil(clients.openWindow(url)); 24 } 25 } catch (e) { 26 // Invalid URL, do nothing 27 } 28 } 29});
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.