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

@@ -1596,9 +1596,10 @@ func (am *DefaultAccountManager) GetAllConnectedPeers() (map[string]struct{}, er
return am.peersUpdateManager.GetAllConnectedPeers(), nil
}
var invalidDomainRegexp = regexp.MustCompile(`^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$`)
func isDomainValid(domain string) bool {
re := regexp.MustCompile(`^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$`)
return re.MatchString(domain)
return invalidDomainRegexp.MatchString(domain)
}
// GetDNSDomain returns the configured dnsDomain