Prepare regexps on compile time (#1327)

This commit is contained in:
Yury Gargay
2023-11-27 13:01:00 +01:00
committed by GitHub
parent 0ca06b566a
commit 63d211c698
7 changed files with 24 additions and 26 deletions

View File

@@ -267,8 +267,9 @@ func validateGroups(list []string, groups map[string]*Group) error {
return nil
}
var domainMatcher = regexp.MustCompile(domainPattern)
func validateDomain(domain string) error {
domainMatcher := regexp.MustCompile(domainPattern)
if !domainMatcher.MatchString(domain) {
return errors.New("domain should consists of only letters, numbers, and hyphens with no leading, trailing hyphens, or spaces")
}