mirror of
https://github.com/un-pany/v3-admin-vite.git
synced 2025-04-21 11:29:20 +08:00
style: validate.ts
This commit is contained in:
parent
45e999e15d
commit
402787bfae
@ -1,4 +1,7 @@
|
||||
export const isExternal = (path: string) => /^(https?:|mailto:|tel:)/.test(path)
|
||||
export const isExternal = (path: string) => {
|
||||
const reg = /^(https?:|mailto:|tel:)/
|
||||
return reg.test(path)
|
||||
}
|
||||
|
||||
export const isArray = (arg: any) => {
|
||||
if (typeof Array.isArray === "undefined") {
|
||||
@ -7,6 +10,13 @@ export const isArray = (arg: any) => {
|
||||
return Array.isArray(arg)
|
||||
}
|
||||
|
||||
export function isString(str: any) {
|
||||
if (typeof str === "string" || str instanceof String) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export const isValidURL = (url: string) => {
|
||||
const reg =
|
||||
/^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
|
||||
|
Loading…
x
Reference in New Issue
Block a user