Skip to content

fix(isEmail): replace all dots in gmail length validation#1718

Merged
profnandaa merged 1 commit into
validatorjs:masterfrom
DasDingGehtNicht:fix-gmail-length-validation
Sep 26, 2021
Merged

fix(isEmail): replace all dots in gmail length validation#1718
profnandaa merged 1 commit into
validatorjs:masterfrom
DasDingGehtNicht:fix-gmail-length-validation

Conversation

@DasDingGehtNicht

@DasDingGehtNicht DasDingGehtNicht commented Aug 30, 2021

Copy link
Copy Markdown
Contributor

The gmail domain specific validator checks the length of the username part and replaces dots as they don't count against the limit. But the replace function only replaced the first dot. Fixed by using regex with g switch.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)

@codecov

codecov Bot commented Aug 30, 2021

Copy link
Copy Markdown

Codecov Report

Merging #1718 (89f02c2) into master (8c4b3b3) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1718   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          101       101           
  Lines         2005      2005           
  Branches       452       452           
=========================================
  Hits          2005      2005           
Impacted Files Coverage Δ
src/lib/isEmail.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c4b3b3...89f02c2. Read the comment docs.

@fedeci fedeci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add test cases?

@DasDingGehtNicht DasDingGehtNicht force-pushed the fix-gmail-length-validation branch from d0aa34a to 89f02c2 Compare August 30, 2021 15:12
@DasDingGehtNicht

Copy link
Copy Markdown
Contributor Author

Could you add test cases?

modified existing test case.
test case: 'some.name.midd.leNa.me.and.locality+extension@GoogleMail.com',
pre-fix: invalid (somename.midd.leNa.me.and.locality = 35 chars)
post-fix: valid (somenamemiddleNameandlocality = 29 chars)

@tux-tn tux-tn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🎉
Nice catch!

@tux-tn tux-tn added ready-to-land For PRs that are reviewed and ready to be landed 🎉 first-pr labels Aug 30, 2021
Comment thread test/validators.js
'test|123@m端ller.com',
'test123+ext@gmail.com',
'some.name.midd.leNa.me+extension@GoogleMail.com',
'some.name.midd.leNa.me.and.locality+extension@GoogleMail.com',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why it was passing the test before? Is the GoogleMail domain part of gmail?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Max length is supposed to be 30 characters without the dots and the email alias (any string after the + character) . Even after removing only one dot the old string length was less than 30

@03-65

03-65 commented Sep 1, 2021

Copy link
Copy Markdown

I have no idea how to code

@03-65

03-65 commented Sep 1, 2021

Copy link
Copy Markdown

Could you add test cases?

modified existing test case.
test case: 'some.name.midd.leNa.me.and.locality+extension@GoogleMail.com',
pre-fix: invalid (somename.midd.leNa.me.and.locality = 35 chars)
post-fix: valid (somenamemiddleNameandlocality = 29 chars)

I don't know what you mean and I'm unable to Upload files it tells me

@03-65

03-65 commented Sep 9, 2021

Copy link
Copy Markdown

Thank you

@profnandaa profnandaa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch, thanks! 🎉

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

Labels

🎉 first-pr ready-to-land For PRs that are reviewed and ready to be landed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants