'use strict'; // Zelfde document bij een hash-wissel. Zonder dit zet de browser het oude // scrollpunt terug, ook als de shell uit de service worker komt. if ('scrollRestoration' in history) history.scrollRestoration = 'manual'; function appScope() { let path = window.location.pathname; if (!path.endsWith('/')) { if (/\.[a-z0-9]+$/i.test(path)) path = path.replace(/[^/]*$/, ''); else path += '/'; } return new URL(path, window.location.origin); } function registerApp() { if (!('serviceWorker' in navigator)) return; const scope = appScope(); const swUrl = new URL('sw.js', scope); const current = document.currentScript; if (current && current.src) { const version = new URL(current.src).searchParams.get('v'); if (version) swUrl.searchParams.set('v', version); } navigator.serviceWorker.register(swUrl.href, { scope: scope.href }).catch(function () {}); } registerApp();