域名后缀只能为字母

This commit is contained in:
lanrenwo
2022-05-31 13:12:30 +08:00
parent 77e507fab7
commit 3e491d33c6

View File

@@ -182,10 +182,6 @@ func CheckDomainNames(domains string) error {
} }
func ValidateDomainName(domain string) bool { func ValidateDomainName(domain string) bool {
pos := strings.LastIndex(domain, ".") RegExp := regexp.MustCompile(`^([a-zA-Z0-9][-a-zA-Z0-9]{0,62}\.)+[A-Za-z]{2,18}$`)
if pos != -1 && len(domain[pos+1:]) < 2 {
return false
}
RegExp := regexp.MustCompile(`^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$`)
return RegExp.MatchString(domain) return RegExp.MatchString(domain)
} }