Skip to content

Commit

Permalink
Use nullish coalescing
Browse files Browse the repository at this point in the history
  • Loading branch information
sstephenson committed Jan 25, 2021
1 parent 8506ede commit a865647
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/core/drive/page_snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class PageSnapshot extends Snapshot<HTMLBodyElement> {
return this.headSnapshot.element
}

get rootLocation(): URL {
const root = this.getSetting("root", "/")
get rootLocation() {
const root = this.getSetting("root") ?? "/"
return expandURL(root)
}

Expand All @@ -54,10 +54,7 @@ export class PageSnapshot extends Snapshot<HTMLBodyElement> {

// Private

getSetting(name: string): string | undefined
getSetting(name: string, defaultValue: string): string
getSetting(name: string, defaultValue?: string) {
const value = this.headSnapshot.getMetaValue(`turbo-${name}`)
return value == null ? defaultValue : value
getSetting(name: string) {
return this.headSnapshot.getMetaValue(`turbo-${name}`)
}
}

0 comments on commit a865647

Please sign in to comment.