-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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 13 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}, | ||
|
Member
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
Member
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -461,6 +461,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.` | ||||||
|
||||||
| 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.` | |
| username_error = ` username can only contain alphanumeric chars ('0-9','a-z','A-Z'), dash ('-'), underscore ('_') and dot ('.'). It cannot begin or end with non-alphanumeric chars, and consecutive non-alphanumeric chars are also forbidden.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.


Uh oh!
There was an error while loading. Please reload this page.