Normalize emails for uniqueness validation. This will convert the email to lowercase, remove dots (.
), and plus signs
followed by arbitrary strings (+foobar
).
Based on normailize.
npm install --save normalize-email
var normalizeEmail = require('normalize-email')
normalizeEmail('johnotander@GMAIL.com') // => 'johnotander@gmail.com'
normalizeEmail('john.o.t.a.n.d.e.r@gmail.com') // => 'johnotander@gmail.com'
normalizeEmail('johnotander@googlemail.com') // => 'johnotander@gmail.com'
normalizeEmail('johnotander+foobar@gmail.com') // => 'johnotander@gmail.com'
normalizeEmail('JOHN.OTANDER+OHAI@gmail.com') // => 'johnotander@gmail.com'
Normalization rules vary by domain. The rules implemented by this package are:
- "plus" — remove first
+
mark and anything after it - "dot" — remove all
.
marks - "none" — do nothing
Emails are normalized by domain as follows:
gmail.com
— plus and dotgooglemail.com
(alias of gmail.com) — plus and dot- hotmail.com — plus only
- live.com — plus and dot
- outlook.com — plus only
- all other domains — none
MIT
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Crafted with <3 by John Otander (@4lpine).
This package was initially generated with yeoman and the p generator.