From: Sean Spade Date: Sat, 10 Jun 2023 03:28:56 +0000 (-0400) Subject: chore: ensures validURL function does not throw exception X-Git-Url: http://these/git/%7B%24%7B%60data:application/%22%7Burl%7D/readmes/static/%7BrepoUrl%7D?a=commitdiff_plain;h=4da24386383a4150dc1634869a6ad11ece1f625f;p=lemmy-ui.git chore: ensures validURL function does not throw exception --- diff --git a/src/shared/utils.ts b/src/shared/utils.ts index df7673a..c9d3e91 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -327,7 +327,12 @@ export function isVideo(url: string) { } export function validURL(str: string) { - return !!new URL(str); + try { + new URL(str); + return true; + } catch (_) { + return false; + } } export function validInstanceTLD(str: string) {