Extract shared NormalizeAlnum into pkg/strutil
The alphanumeric-normalisation helper was duplicated verbatim in the common-third-party owned-domains resolver and the cookiebanner tracker mapping worker. Hoist it into a new dependency-free strutil package so both call sites share one implementation and one test. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -130,32 +130,6 @@ func TestNameIsCookieDatabaseAggregator(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeAlnum(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
expected string
|
||||
}{
|
||||
{name: "letters lowercased", input: "Letaido", expected: "letaido"},
|
||||
{name: "strips punctuation and spaces", input: "letaido.com - Inc", expected: "letaidocominc"},
|
||||
{name: "keeps digits", input: "auth0", expected: "auth0"},
|
||||
{name: "empty", input: "", expected: ""},
|
||||
{name: "only punctuation", input: "-_.:", expected: ""},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(
|
||||
tt.name,
|
||||
func(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.Equal(t, tt.expected, normalizeAlnum(tt.input))
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildAgentPrompt(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user