# UserNameSuggester suggests names with trailing underscores

**URL:** https://meta.discourse.org/t/usernamesuggester-suggests-names-with-trailing-underscores/32964
**Category:** Bug
**Created:** [06.Сентябрь.2015 17:55:50 UTC](https://meta.discourse.org/t/usernamesuggester-suggests-names-with-trailing-underscores/32964 "2015-09-06T17:55:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![JSey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jsey/32/3540_2.png) [@JSey](https://meta.discourse.org/u/JSey)
#### Post date: [06.Сентябрь.2015 17:55:50 UTC](https://meta.discourse.org/t/usernamesuggester-suggests-names-with-trailing-underscores/32964/1 "2015-09-06T17:55:50Z")

</div>

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

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

```

and replace accordingly (how?).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [06.Сентябрь.2015 20:34:36 UTC](https://meta.discourse.org/t/usernamesuggester-suggests-names-with-trailing-underscores/32964/2 "2015-09-06T20:34:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [11.Сентябрь.2015 10:55:43 UTC](https://meta.discourse.org/t/usernamesuggester-suggests-names-with-trailing-underscores/32964/3 "2015-09-11T10:55:43Z")

</div>

Trailing underscore in username is now allowed:

[https://github.com/discourse/discourse/commit/b3d2982be7d40ff632afcd1c3cbe8c9e78a632be](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](https://github.com/discourse/discourse/commit/d73d4d476984d6de647423d3869cfdb1d72c427a)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [11.Сентябрь.2015 11:47:18 UTC](https://meta.discourse.org/t/usernamesuggester-suggests-names-with-trailing-underscores/32964/4 "2015-09-11T11:47:18Z")

</div>


