Skip to content

Commit

Permalink
fix: 修改合法用户名账号名模式
Browse files Browse the repository at this point in the history
  • Loading branch information
link89 committed Oct 31, 2024
1 parent 954f678 commit b88882d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,10 @@ func GetUserNameByUid(uid int) (string, error) {
return u.Username, nil
}

// 判断字符串中是否包含大写字母
// 判断字符串是否为合法用户名或账号名
func CheckAccountOrUserStrings(s string) bool {
pattern := "^[a-z0-9_]+$"
// 允许字母、数字、下划线、连字符
pattern := "^[a-zA-Z0-9_-]+$"
// 编译正则表达式
reg := regexp.MustCompile(pattern)
// 使用正则表达式判断字符串是否符合模式
Expand Down

0 comments on commit b88882d

Please sign in to comment.