mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-07 00:17:03 +08:00
🔨 Refactor: rewrite func isUrl
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user