code-server/src/browser/register.ts
Asher 938b460685
Add trailing slash to service worker scope
This will ensure it always matches or is underneath the allowed service
worker scope.

Fixes #2076.
2020-09-09 12:05:04 -05:00

18 lines
451 B
TypeScript

import { getOptions, normalize } from "../common/util"
const options = getOptions()
import "./pages/error.css"
import "./pages/global.css"
import "./pages/login.css"
if ("serviceWorker" in navigator) {
const path = normalize(`${options.csStaticBase}/dist/serviceWorker.js`)
navigator.serviceWorker
.register(path, {
scope: (options.base ?? "") + "/",
})
.then(() => {
console.log("[Service Worker] registered")
})
}