Skip to content

Commit 6e9bc6e

Browse files
authored
do not crash dashboard when externalLinkForPage fails (#5724)
1 parent f7acb06 commit 6e9bc6e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • assets/js/dashboard/util

assets/js/dashboard/util/url.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ export function apiPath(
1010
export function externalLinkForPage(
1111
domain: PlausibleSite['domain'],
1212
page: string
13-
): string {
14-
const domainURL = new URL(`https://${domain}`)
15-
return `https://${domainURL.host}${page}`
13+
): string | null {
14+
try {
15+
const domainURL = new URL(`https://${domain}`)
16+
return `https://${domainURL.host}${page}`
17+
} catch (_error) {
18+
return null
19+
}
1620
}
1721

1822
export function isValidHttpUrl(input: string): boolean {

0 commit comments

Comments
 (0)