Skip to content

Commit

Permalink
chore: replace dots in ipv4 addresses with slashes
Browse files Browse the repository at this point in the history
Signed-off-by: Rolf Ahrenberg <[email protected]>
  • Loading branch information
rofafor committed Nov 26, 2024
1 parent bb045f0 commit de92f94
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/utilities.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package utils

import (
"regexp"
"strings"

pb "github.com/envoyproxy/go-control-plane/envoy/service/ratelimit/v3"
Expand Down Expand Up @@ -65,5 +66,9 @@ func MaskCredentialsInUrl(url string) string {
// Remove invalid characters from the stat name.
func SanitizeStatName(s string) string {
r := strings.NewReplacer(":", "_", "|", "_")
return r.Replace(s)
ipv4Pattern := `\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}`
re := regexp.MustCompile(ipv4Pattern)
return re.ReplaceAllStringFunc(r.Replace(s), func(ip string) string {
return strings.ReplaceAll(ip, ".", "_")
})
}

0 comments on commit de92f94

Please sign in to comment.