mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-28 10:53:20 +01:00
19 lines
494 B
Go
19 lines
494 B
Go
package util
|
|
|
|
import "strings"
|
|
|
|
// ConvertGroupAndServiceToKey converts a group and a service to a key
|
|
func ConvertGroupAndServiceToKey(group, service string) string {
|
|
return sanitize(group) + "_" + sanitize(service)
|
|
}
|
|
|
|
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
|
|
}
|