Skip to content

Commit

Permalink
fix: 修改合法账号名模式
Browse files Browse the repository at this point in the history
  • Loading branch information
link89 committed Nov 1, 2024
1 parent 2352e26 commit aa3d2c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
@@ -338,8 +338,8 @@ func GetUserNameByUid(uid int) (string, error) {

// 判断字符串是否为合法用户名或账号名
func CheckAccountOrUserStrings(s string) bool {
// 允许小写字母、数字、下划线、连字符
pattern := "^[a-z0-9_-]+$"
// 允许小写字母、数字、下划线、连字符, 不以连字符开头
pattern := "^(?!-)[a-z0-9_-]+$"
// 编译正则表达式
reg := regexp.MustCompile(pattern)
// 使用正则表达式判断字符串是否符合模式

0 comments on commit aa3d2c7

Please sign in to comment.