fix: 修复isUrl判断错误bug #526

This commit is contained in:
clddup 2024-09-02 08:54:42 +00:00
parent 0e99f8374a
commit 3cd89bdd09
1 changed files with 6 additions and 3 deletions

View File

@ -95,9 +95,12 @@ export const isServer = typeof window === 'undefined'
export const isClient = !isServer export const isClient = !isServer
export const isUrl = (path: string): boolean => { export const isUrl = (path: string): boolean => {
const reg = try {
/(((^https?:(?:\/\/)?)(?:[-:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&%@.\w_]*)#?(?:[\w]*))?)$/ new URL(path)
return reg.test(path) return true
} catch (_error) {
return false
}
} }
export const isDark = (): boolean => { export const isDark = (): boolean => {