Files
onepanel/pkg/util/uid/uid.go
Aleksandr Melnikov b89a31323d Fixing error message.
- This is specific to us because of how we combine uid and namespace to create the subdomain.
2020-05-14 10:29:55 -07:00

17 lines
359 B
Go

package uid
import (
"errors"
"regexp"
"strings"
)
func GenerateUID(input string) (string, error) {
re, _ := regexp.Compile(`[^a-zA-Z0-9-]{1,}`)
cleanUp := strings.ToLower(re.ReplaceAllString(input, `-`))
if len(cleanUp) > 30 {
return "", errors.New("Length of string exceeds 30.")
}
return strings.ToLower(re.ReplaceAllString(input, `-`)), nil
}