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

Always remove spaces from email and username #1280

Merged
merged 7 commits into from
Mar 8, 2018
Merged

Conversation

luisrudge
Copy link
Contributor

fix #1180

@luisrudge luisrudge added this to the v11.4.0 milestone Mar 1, 2018
});
describe('setEmail()', () => {
it(`removes spaces`, () => {
email.setEmail(Immutable.fromJS({}), ' email@te st.com ');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I agree leading and trailing whitespaces should be trimmed, i think having whitespaces on the middle of an email address or username is an "invalid value" rather.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why show "invalid field" if we can remove them at once and move on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just typing this out, actually. Fully agree (if spaces are actually invalid characters ... are they excluded by the platform?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's a user's typing error and we should point them that it's an invalid value and they should fix it. If we don't, they might think they registered using "this email @address.com" and when they try to log in on other platform they won't be allowed.

Also, A0 username regex: ^[a-zA-Z0-9_]+$

Screenshot below from gmail when typing an email address:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -15,8 +15,8 @@ export function isEmail(str) {
return !!result && result[0] !== null;
}

export function setEmail(m, str) {
return setField(m, 'email', str, str => {
export function setEmail(m, str = '') {
Copy link
Contributor

@lbalmaceda lbalmaceda Mar 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're adding a default value here (if str is not present). Isn't this breaking further validation? I know you do this so you can call trim without checking the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to be sure you would not get null/undefined, but the code is already not throwing here, so we're fine.

Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine!

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

Successfully merging this pull request may close these issues.

Whitespace not being trimmed for email input when username_required
3 participants