mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
feat: 前后端域名校验保持一致 (#2842)
This commit is contained in:
parent
1a820e00ff
commit
8599a858e4
@ -222,7 +222,10 @@ func ConvertToPinyin(text string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsValidDomain(domain string) bool {
|
func IsValidDomain(domain string) bool {
|
||||||
pattern := `^([\w\\u4e00-\\u9fa5\\-\\*]{1,100}\.){1,10}([\w\\u4e00-\\u9fa5\\-]{1,24}|[\w\\u4e00-\\u9fa5\\-]{1,24}\.[\w\\u4e00-\\u9fa5\\-]{1,24})$`
|
pattern := `^([\w\p{Han}\-\*]{1,100}\.){1,10}([\w\p{Han}\-]{1,24}|[\w\p{Han}\-]{1,24}\.[\w\p{Han}\-]{1,24})(:\d{1,5})?$`
|
||||||
match, _ := regexp.MatchString(pattern, domain)
|
match, err := regexp.MatchString(pattern, domain)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return match
|
return match
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user