mirror of
https://github.com/TwiN/gatus.git
synced 2024-12-23 07:09:52 +01:00
6ed93d4b82
* Add clarifications in comments * #191: Rename Service to Endpoint
19 lines
508 B
Go
19 lines
508 B
Go
package util
|
|
|
|
import "strings"
|
|
|
|
// ConvertGroupAndEndpointNameToKey converts a group and an endpoint to a key
|
|
func ConvertGroupAndEndpointNameToKey(group, endpoint string) string {
|
|
return sanitize(group) + "_" + sanitize(endpoint)
|
|
}
|
|
|
|
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
|
|
}
|