fix(key): Support (, ), + and & as name/group (#1340)
fix(key): Support (, ), + and & as name/group Relevant: #1339
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user