Skip to content

Commit

Permalink
update source tag normalization to include :
Browse files Browse the repository at this point in the history
  • Loading branch information
austin-denoble committed Jun 7, 2024
1 parent 604d8df commit 74d08cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/useragent/useragent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
5 changes: 5 additions & 0 deletions internal/useragent/useragent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 74d08cb

Please sign in to comment.