Skip to content
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

Properly allowing for spaces on usernames #1107

Open
andrevenancio opened this issue Aug 25, 2021 · 1 comment
Open

Properly allowing for spaces on usernames #1107

andrevenancio opened this issue Aug 25, 2021 · 1 comment

Comments

@andrevenancio
Copy link
Contributor

andrevenancio commented Aug 25, 2021

The new username on SUBKJT contract allow for multiple spaces.

Below are some suggestions for fix an issue where the names are displayed with a %20 instead of a space.

When displaying names on the website I would suggest:

  • Trim any spaces at the beginning of the sentence
  • Trim any spaces at the end of the sentence
  • Trim more than 1 pace in the middle.

So for example:

Input on SUBJK form Currently Renders as
"Andre Venancio" Andre%20Venancio
" Andre Venancio " %20%20Andre%20Venancio%20%20
"Andre Venancio" Andre%20%20Venancio

You can solve the spaces being transformed to %20 by running either:
str.replace(/%20/g, " ") or decodeURI(str)

But that doesn't trim any extra apace in the beginning, not the end or the name, nor it does remove any double spaces in between the first and last name.

For that, I would suggest:

str.replace(/\s+/g, " ").

So the overall code would be

const trimName = (str) => {
  return decodeURI(str).replace(/\s+/g, " ");
}

As for the %20 on the URL, thats probably the desired solution, however, I would consider substituting the %20 for a - or a _. So hicetnunc.xyz/andre-venancio instead of hicetnunc.xyz/andre%20venancio

@kylegrover
Copy link
Collaborator

kylegrover commented Aug 26, 2021

I think the big issues that lead to deciding to render the %20 were impersonation and url conflicts. I haven't had time to fully think this through but there are probably some places where we can safely render a sanitized name but other places where we need to make it explicitly clear when there's an extra space.
Users also probably shouldn't be relying on names as a validation method but I reckon they do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants