2021-01-28 00:25:37 +01:00
|
|
|
package util
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
2021-10-23 22:47:12 +02:00
|
|
|
// ConvertGroupAndEndpointNameToKey converts a group and an endpoint to a key
|
|
|
|
func ConvertGroupAndEndpointNameToKey(group, endpoint string) string {
|
|
|
|
return sanitize(group) + "_" + sanitize(endpoint)
|
2021-01-28 00:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func sanitize(s string) string {
|
|
|
|
s = strings.TrimSpace(strings.ToLower(s))
|
|
|
|
s = strings.ReplaceAll(s, "/", "-")
|
|
|
|
s = strings.ReplaceAll(s, "_", "-")
|
|
|
|
s = strings.ReplaceAll(s, ".", "-")
|
|
|
|
s = strings.ReplaceAll(s, ",", "-")
|
|
|
|
s = strings.ReplaceAll(s, " ", "-")
|
|
|
|
return s
|
|
|
|
}
|