Skip to content

Commit

Permalink
Handle @ in user part of email, closes #594
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Oct 15, 2016
1 parent ea7b270 commit b1b6c1e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#### HEAD

- New locales
([#585](https://github.com/chriso/validator.js/pull/585))
- Added support for greater or less than in `isFloat()`
([#544](https://github.com/chriso/validator.js/issues/544))
- Added support for ISSN validation via `isISSN()`
([#593](https://github.com/chriso/validator.js/pull/593))
- Fixed a bug in `normalizeEmail()`
([#594](https://github.com/chriso/validator.js/issues/594))
- New locales
([#585](https://github.com/chriso/validator.js/pull/585))

#### 6.0.0

Expand Down
6 changes: 5 additions & 1 deletion lib/normalizeEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ function normalizeEmail(email, options) {
if (!(0, _isEmail2.default)(email)) {
return false;
}
var parts = email.split('@', 2);

var raw_parts = email.split('@');
var domain = raw_parts.pop();
var user = raw_parts.join('@');
var parts = [user, domain];

// The domain is always lowercased, as it's case-insensitive per RFC 1035
parts[1] = parts[1].toLowerCase();
Expand Down
6 changes: 5 additions & 1 deletion src/lib/normalizeEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ export default function normalizeEmail(email, options) {
if (!isEmail(email)) {
return false;
}
const parts = email.split('@', 2);

const raw_parts = email.split('@');
const domain = raw_parts.pop();
const user = raw_parts.join('@');
const parts = [user, domain];

// The domain is always lowercased, as it's case-insensitive per RFC 1035
parts[1] = parts[1].toLowerCase();
Expand Down
1 change: 1 addition & 0 deletions test/sanitizers.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ describe('Sanitizers', function () {
'[email protected]': false,
'[email protected]': false,
'[email protected]': '[email protected]',
'"foo@bar"@baz.com': '"foo@bar"@baz.com',
},
});

Expand Down
6 changes: 5 additions & 1 deletion validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,11 @@
if (!isEmail(email)) {
return false;
}
var parts = email.split('@', 2);

var raw_parts = email.split('@');
var domain = raw_parts.pop();
var user = raw_parts.join('@');
var parts = [user, domain];

// The domain is always lowercased, as it's case-insensitive per RFC 1035
parts[1] = parts[1].toLowerCase();
Expand Down
2 changes: 1 addition & 1 deletion validator.min.js

Large diffs are not rendered by default.

0 comments on commit b1b6c1e

Please sign in to comment.