mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-18 02:50:43 +02:00
Prepare regexps on compile time (#1327)
This commit is contained in:
@@ -86,6 +86,8 @@ func (s SimpleRecord) Len() uint16 {
|
||||
}
|
||||
}
|
||||
|
||||
var invalidHostMatcher = regexp.MustCompile(invalidHostLabel)
|
||||
|
||||
// GetParsedDomainLabel returns a domain label with max 59 characters,
|
||||
// parsed for old Hosts.txt requirements, and converted to ASCII and lowercase
|
||||
func GetParsedDomainLabel(name string) (string, error) {
|
||||
@@ -99,8 +101,6 @@ func GetParsedDomainLabel(name string) (string, error) {
|
||||
return "", fmt.Errorf("unable to convert host label to ASCII, error: %v", err)
|
||||
}
|
||||
|
||||
invalidHostMatcher := regexp.MustCompile(invalidHostLabel)
|
||||
|
||||
validHost := strings.ToLower(invalidHostMatcher.ReplaceAllString(ascii, "-"))
|
||||
if len(validHost) > 58 {
|
||||
validHost = validHost[:59]
|
||||
|
Reference in New Issue
Block a user