Initial commit (code only without large binaries)
This commit is contained in:
19
EdgeUser/internal/utils/domainutils/utils.go
Normal file
19
EdgeUser/internal/utils/domainutils/utils.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package domainutils
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ValidateDomainFormat 校验域名格式
|
||||
func ValidateDomainFormat(domain string) bool {
|
||||
pieces := strings.Split(domain, ".")
|
||||
for _, piece := range pieces {
|
||||
// \p{Han} 中文unicode字符集
|
||||
if !regexp.MustCompile(`^[\p{Han}a-z0-9-]+$`).MatchString(piece) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user