Skip to content

Commit 42cadb1

Browse files
Do not fail to load options page if stored URL is invalid.
1 parent 4e648dc commit 42cadb1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/options.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,14 @@ const Options: React.FunctionComponent<Props> = ({ sandbox }) => {
431431
checkHasHostPermission(apiUrl).then((result) => {
432432
setHasHostPermission(result);
433433
});
434-
setApiUrlObj(new URL(apiUrl));
434+
let url;
435+
try {
436+
url = new URL(apiUrl);
437+
} catch (e) {
438+
// If we couldn't parse the URL, just revert to default
439+
url = new URL(DEFAULT_API_URL);
440+
}
441+
setApiUrlObj(url);
435442
}, [apiUrl]);
436443

437444
useEffect(() => {

0 commit comments

Comments
 (0)