mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 08:44:04 +01:00
17 lines
348 B
Go
17 lines
348 B
Go
package dns
|
||
|
||
import (
|
||
"regexp"
|
||
)
|
||
|
||
var labelRegex = regexp.MustCompile(`^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$`)
|
||
|
||
// IsLabel returns true if s is a valid DNS label per our rules: lowercase, [a-z0-9-], 1–32 chars, starts/ends alnum.
|
||
func IsLabel(s string) bool {
|
||
if s == "" || len(s) > 32 {
|
||
return false
|
||
}
|
||
|
||
return labelRegex.MatchString(s)
|
||
}
|