chriso/validator.js — pull request #320 by EgoAleSum (2014-10-06 18:48:44+00:00)
Title: validator.normalizeEmail improvements

I made some improvements to validator.normalizeEmail:

1. It rejects (returning false) non valid email addresses. A sanitizer, indeed, should first of all make sure it's dealing with valid emails, in my opinion.

2. Since not all email providers are case-insensitive with the local part of the email address, an option was added to not lowercase that part for all hostnames (believe it or not, I know people with case-sensitive email addresses - and of course their company gave them uppercase letters inside! - this is 100% valid per RFC).
However: the hostname is always lowercased and the local part of hosts known for being case-insensitive (currently, only gmail/googlemail) is always lowercased.

3. Added an option to normalize googlemail.com email addresses to gmail.com .

Please note: per issue #258 I had to remove a couple of existing test cases, as they were failing on validator.isEmail.