fix(key): Support (, ), + and & as name/group (#1340)

fix(key): Support (, ), + and & as name/group

Relevant: #1339
This commit is contained in:
TwiN
2025-10-16 16:47:11 -04:00
committed by GitHub
parent 39981de54b
commit ebd4068aac
3 changed files with 28 additions and 9 deletions

View File

@@ -15,5 +15,9 @@ func sanitize(s string) string {
s = strings.ReplaceAll(s, ",", "-")
s = strings.ReplaceAll(s, " ", "-")
s = strings.ReplaceAll(s, "#", "-")
s = strings.ReplaceAll(s, "(", "-")
s = strings.ReplaceAll(s, ")", "-")
s = strings.ReplaceAll(s, "+", "-")
s = strings.ReplaceAll(s, "&", "-")
return s
}
}

View File

@@ -29,6 +29,21 @@ func TestConvertGroupAndNameToKey(t *testing.T) {
Name: "name",
ExpectedOutput: "_name",
},
{
GroupName: "API (v1)",
Name: "endpoint",
ExpectedOutput: "api--v1-_endpoint",
},
{
GroupName: "website (admin)",
Name: "test",
ExpectedOutput: "website--admin-_test",
},
{
GroupName: "search",
Name: "query&filter",
ExpectedOutput: "search_query-filter",
},
}
for _, scenario := range scenarios {
t.Run(scenario.ExpectedOutput, func(t *testing.T) {