-
Notifications
You must be signed in to change notification settings - Fork 11
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
replace special chars in user names #93
replace special chars in user names #93
Conversation
|
||
var specialCharRegexp = regexp.MustCompile("[^A-Za-z0-9]") | ||
|
||
func sanitizeUserName(userName string) string { |
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.
before you start asking why I didn't use the already existing functions, I was thinking about it, but decided to use this simple option, the reasons are:
- transforming username from toolchain-common - the usage is different, it cuts the name of the username (to keep it short) as it expects that it would be used together with the namespace/space suffixes. It also does some assumptions with
@
char. - transforming usersignup name that is in registration service - yes, we could use this one, but we would need to move it to toolchain-common first. However, I thought that we don't need any extra logic of generating the sha in case there is some special char in the username. TBH, the risk of having a conflict of the names is very low, so I would rather keep it simple and let the transformation that is in reg-service fully optimized for the usage for UserSignup names.
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.
Thanks for this explanation :D
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.
Would this be an add-on to #92 ?
let me close this one - it should rather fail if the name is not compliant than doing some additional replacements |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #93 +/- ##
==========================================
+ Coverage 67.78% 67.84% +0.05%
==========================================
Files 44 44
Lines 3216 3222 +6
==========================================
+ Hits 2180 2186 +6
Misses 841 841
Partials 195 195
|
the correct fix is here: #94 |
so the username can be used as the name of the User resource as well as the label value