dot is valid for username (#2958)

* dot is valid for username in gitlab
* add test case for user
This commit is contained in:
Kian Ostad 2021-03-16 19:20:34 +03:30 committed by GitHub
parent d881724695
commit 6b27829426
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -94,7 +94,7 @@ func (u *User) Validate() error {
switch {
case !govalidator.IsByteLength(u.Login, 1, 50):
return errUsernameLen
case !govalidator.Matches(u.Login, "^[a-zA-Z0-9_-]+$"):
case !govalidator.Matches(u.Login, "^[.a-zA-Z0-9_-]+$"):
return errUsernameChar
default:
return nil

View file

@ -39,6 +39,10 @@ func TestValidateUser(t *testing.T) {
user: &User{Login: "octocat"},
err: nil,
},
{
user: &User{Login: "octocat.with.dot"},
err: nil,
},
{
user: &User{Login: "OctO-Cat_01"},
err: nil,