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%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/%7Bthis.props.imageSrc%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) {