remove use of URL.canParse

This commit is contained in:
Samuel Newman
2026-08-13 10:12:12 +03:00
parent 33940bd6b2
commit a940fa1c80
2 changed files with 11 additions and 1 deletions
+9
View File
@@ -27,6 +27,15 @@ const TRUSTED_REGEX = new RegExp(
)})|/|#)`,
)
export function canParseUrl(url: string | URL, base?: string | URL): boolean {
try {
new URL(url, base)
return true
} catch {
return false
}
}
export function isValidDomain(str: string): boolean {
return !!TLDs.find(tld => {
let i = str.lastIndexOf(tld)