Skip to content

Commit

Permalink
Do not fail to load options page if stored URL is invalid.
Browse files Browse the repository at this point in the history
  • Loading branch information
coddingtonbear committed Oct 30, 2024
1 parent 4e648dc commit 42cadb1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,14 @@ const Options: React.FunctionComponent<Props> = ({ sandbox }) => {
checkHasHostPermission(apiUrl).then((result) => {
setHasHostPermission(result);
});
setApiUrlObj(new URL(apiUrl));
let url;
try {
url = new URL(apiUrl);
} catch (e) {
// If we couldn't parse the URL, just revert to default
url = new URL(DEFAULT_API_URL);
}
setApiUrlObj(url);
}, [apiUrl]);

useEffect(() => {
Expand Down

0 comments on commit 42cadb1

Please sign in to comment.