🔨 Refactor: rewrite func isUrl

This commit is contained in:
萌萌哒赫萝 2023-03-01 10:37:58 +08:00
parent b42c8608bc
commit d0362e226e

View File

@ -1,4 +1,12 @@
export const isUrl = (url: string): boolean => (/^https?:\/\//.test(url)) export const isUrl = (url: string): boolean => {
try {
new URL(url)
return true
} catch {
return false
}
}
export const isUrlEncode = (url: string): boolean => { export const isUrlEncode = (url: string): boolean => {
url = url || '' url = url || ''
try { try {