diff --git a/internal/useragent/useragent.go b/internal/useragent/useragent.go index 66b6a5b..2079a7d 100644 --- a/internal/useragent/useragent.go +++ b/internal/useragent/useragent.go @@ -36,7 +36,7 @@ func buildSourceTagField(userAgent string) string { // Limit charset to [a-z0-9_ ] var strBldr strings.Builder for _, char := range userAgent { - if (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9') || char == '_' || char == ' ' { + if (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9') || char == '_' || char == ' ' || char == ':' { strBldr.WriteRune(char) } } diff --git a/internal/useragent/useragent_test.go b/internal/useragent/useragent_test.go index 16bf7f0..f16798c 100644 --- a/internal/useragent/useragent_test.go +++ b/internal/useragent/useragent_test.go @@ -78,4 +78,9 @@ func TestBuildUserAgentSourceTagIsNormalized(t *testing.T) { if !strings.Contains(result, "source_tag=my_source_tag") { t.Errorf("BuildUserAgent(\"%s\"): expected user-agent to contain 'source_tag=my_source_tag_123', but got %s", sourceTag, result) } + + sourceTag = " My Source Tag 123 : !! " + if !strings.Contains(result, "source_tag=my_source_tag:") { + t.Errorf("BuildUserAgent(\"%s\"): expected user-agent to contain 'source_tag=my_source_tag_123', but got %s", sourceTag, result) + } }