Skip to content

Commit

Permalink
Use strings instead of regex for splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Grumböck committed May 18, 2020
1 parent 03db178 commit 6cb9443
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions registry/txt.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -224,8 +223,7 @@ func (pr affixNameMapper) toEndpointName(txtDNSName string) string {
}

if len(pr.suffix) > 0 {
regex := regexp.MustCompile(`\.`)
DNSName := regex.Split(lowerDNSName, 2)
DNSName := strings.SplitN(lowerDNSName, ".", 2)
if strings.HasSuffix(DNSName[0], pr.suffix) {
return strings.TrimSuffix(DNSName[0], pr.suffix) + "." + DNSName[1]
}
Expand All @@ -234,8 +232,7 @@ func (pr affixNameMapper) toEndpointName(txtDNSName string) string {
}

func (pr affixNameMapper) toTXTName(endpointDNSName string) string {
regex := regexp.MustCompile(`\.`)
DNSName := regex.Split(endpointDNSName, 2)
DNSName := strings.SplitN(endpointDNSName, ".", 2)
return pr.prefix + DNSName[0] + pr.suffix + "." + DNSName[1]
}

Expand Down

0 comments on commit 6cb9443

Please sign in to comment.