mirror of
https://github.com/openziti/zrok.git
synced 2024-11-25 17:43:53 +01:00
19 lines
423 B
Go
19 lines
423 B
Go
package util
|
|
|
|
import (
|
|
goaway "github.com/TwiN/go-away"
|
|
"regexp"
|
|
)
|
|
|
|
// IsValidUniqueName ensures that the string represents a valid unique name. Lowercase alphanumeric only. 4-32 characters.
|
|
func IsValidUniqueName(uniqueName string) bool {
|
|
match, err := regexp.Match("^[a-z0-9]{4,32}$", []byte(uniqueName))
|
|
if err != nil {
|
|
return false
|
|
}
|
|
if match && goaway.IsProfane(uniqueName) {
|
|
return false
|
|
}
|
|
return match
|
|
}
|