photoprism/pkg/sanitize/username.go

19 lines
313 B
Go
Raw Normal View History

package sanitize
import (
"strings"
"github.com/photoprism/photoprism/pkg/txt"
)
// Username returns the normalized username (lowercase, whitespace trimmed).
func Username(s string) string {
s = strings.TrimSpace(s)
if s == "" || reject(s, txt.ClipUsername) {
return ""
}
return strings.ToLower(s)
}