mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-27 05:00:25 +08:00
19 lines
295 B
Go
19 lines
295 B
Go
package domainutils
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
// 校验域名格式
|
|
func ValidateDomainFormat(domain string) bool {
|
|
pieces := strings.Split(domain, ".")
|
|
for _, piece := range pieces {
|
|
if !regexp.MustCompile(`^[a-z0-9-]+$`).MatchString(piece) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|