-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Improve valid user name check #20136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
0f5c5ee
70fe59a
edab085
54c673b
4b624c7
94d79ce
4a35fec
b203f62
138a2b5
d2f2ba1
0bcd62f
2f72fd5
0ba8593
2e82b61
6bcde7b
e957aa1
5ef6c02
1f53ec0
f61c613
e0506f5
8f904dd
4ffb9c8
a5eac54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,3 +155,30 @@ func Test_IsValidExternalTrackerURLFormat(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestIsValidUsername(t *testing.T) { | ||
tests := []struct { | ||
arg string | ||
want bool | ||
}{ | ||
{arg: "a", want: true}, | ||
{arg: "abc", want: true}, | ||
{arg: "0.b-c", want: true}, | ||
{arg: "a.b-c_d", want: true}, | ||
{arg: "", want: false}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think edge case tests such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
{arg: ".abc", want: false}, | ||
{arg: "abc.", want: false}, | ||
{arg: "a..bc", want: false}, | ||
{arg: "a...bc", want: false}, | ||
{arg: "a.-bc", want: false}, | ||
{arg: "a._bc", want: false}, | ||
{arg: "a_-bc", want: false}, | ||
{arg: "a/bc", want: false}, | ||
{arg: "☁️", want: false}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.arg, func(t *testing.T) { | ||
assert.Equalf(t, tt.want, IsValidUsername(tt.arg), "IsValidUsername(%v)", tt.arg) | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -463,6 +463,7 @@ url_error = `'%s' is not a valid URL.` | |||||
include_error = ` must contain substring '%s'.` | ||||||
glob_pattern_error = ` glob pattern is invalid: %s.` | ||||||
regex_pattern_error = ` regex pattern is invalid: %s.` | ||||||
username_error = ` should contain only alphanumeric, dash ('-'), underscore ('_') and dot ('.') characters, and cannot begin or end with non-alphanumeric, consecutive non-alphanumerics are also not allowed.` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the other translations mention explicitly the faulty type, should we perhaps prepend
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
unknown_error = Unknown error: | ||||||
captcha_incorrect = The CAPTCHA code is incorrect. | ||||||
password_not_match = The passwords do not match. | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.