Skip to content

Commit 67dbb36

Browse files
committed
refactor: remove null check in register.ts options.base
Inside registerServiceWorker, we were originally using the nullash coalescing operator to check if options.base was null or undefined. However, I realized this check is not necessary. If you look at getOptions' return value, we return an object with a key "base" which is of type "string". We get that value by calling resolveBase which always returns a string. As a result, we didn't need to check if options.base was null or undefined because it never can be.
1 parent 6f2709b commit 67dbb36

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/browser/register.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import "./pages/error.css"
44
import "./pages/global.css"
55
import "./pages/login.css"
66

7-
async function registerServiceWorker(): Promise<void> {
7+
export async function registerServiceWorker(): Promise<void> {
88
const options = getOptions()
99
const path = normalize(`${options.csStaticBase}/dist/serviceWorker.js`)
1010
try {
1111
await navigator.serviceWorker.register(path, {
12-
scope: (options.base ?? "") + "/",
12+
scope: options.base + "/",
1313
})
1414
console.log("[Service Worker] registered")
1515
} catch (error) {

0 commit comments

Comments
 (0)