diff --git a/src/utils/accounts.ts b/src/utils/accounts.ts index a320c581..66737474 100644 --- a/src/utils/accounts.ts +++ b/src/utils/accounts.ts @@ -1,23 +1,18 @@ function sanitizeWebsite(website: string | undefined): string | undefined { if (!website) return undefined; - if ( - 'https://'.includes(website) || - 'http://'.includes(website) - ) return undefined; - try { // See if 'website' is a valid url new URL(website); return website; } catch (_) { try { - const websiteWithPrefix = 'https://' + website; + const prefixed = 'https://' + website; // 'website' could still be a valid url // try adding a 'https' prefix to 'website' - new URL(websiteWithPrefix); + new URL(prefixed); - return websiteWithPrefix; + return prefixed; } catch (_) { // 'website' is not a valid url even with 'https' prefix return undefined;