blog/models/users/utils.go

16 lines
286 B
Go
Raw Permalink Normal View History

package users
import (
"regexp"
"strings"
)
// Normalize lowercases and safens a username.
func Normalize(username string) string {
username = strings.ToLower(username)
// Strip special characters.
re := regexp.MustCompile(`[./\\]+`)
return re.ReplaceAllString(username, "")
}