UserNameSuggester suggests names with trailing underscores

I ran into several user errors: ["Username must end with a letter or number"] because UserNameSuggester seems to be oblivious to this restriction. We should introduce something like

name[-1,1] =~ /[^A-Za-z0-9]/

and replace accordingly (how?).

Yes, @techapj and @sam are aware that the username suggester now has a lot of bugs as a result of the rules @sam changed to relax username rules.

Trailing underscore in username is now allowed:

https://github.com/discourse/discourse/commit/b3d2982be7d40ff632afcd1c3cbe8c9e78a632be

However UserNameSuggester still suggests usernames with a sequence of 2 or more special chars (like arpit__jalan) which is not valid. I am working on a fix for that. Fixed:

https://github.com/discourse/discourse/commit/d73d4d476984d6de647423d3869cfdb1d72c427a

5 Likes