Skip to content

Commit

Permalink
Add new option for yandex, re #807
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed May 4, 2018
1 parent 40663e2 commit 3cd87cb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/normalizeEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ var default_normalize_email_options = {
// Removes the subaddress (e.g. "-foo") from the email address
yahoo_remove_subaddress: true,

// The following conversions are specific to Yandex
// Lowercases the local part of the Yandex address (known to be case-insensitive)
yandex_lowercase: true,

// The following conversions are specific to iCloud
// Lowercases the local part of the iCloud address (known to be case-insensitive)
icloud_lowercase: true,
Expand Down Expand Up @@ -133,7 +137,7 @@ function normalizeEmail(email, options) {
parts[0] = parts[0].toLowerCase();
}
} else if (~yandex_domains.indexOf(parts[1])) {
if (options.all_lowercase || options.yahoo_lowercase) {
if (options.all_lowercase || options.yandex_lowercase) {
parts[0] = parts[0].toLowerCase();
}
parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
Expand Down
6 changes: 5 additions & 1 deletion src/lib/normalizeEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const default_normalize_email_options = {
// Removes the subaddress (e.g. "-foo") from the email address
yahoo_remove_subaddress: true,

// The following conversions are specific to Yandex
// Lowercases the local part of the Yandex address (known to be case-insensitive)
yandex_lowercase: true,

// The following conversions are specific to iCloud
// Lowercases the local part of the iCloud address (known to be case-insensitive)
icloud_lowercase: true,
Expand Down Expand Up @@ -225,7 +229,7 @@ export default function normalizeEmail(email, options) {
parts[0] = parts[0].toLowerCase();
}
} else if (~yandex_domains.indexOf(parts[1])) {
if (options.all_lowercase || options.yahoo_lowercase) {
if (options.all_lowercase || options.yandex_lowercase) {
parts[0] = parts[0].toLowerCase();
}
parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
Expand Down
6 changes: 5 additions & 1 deletion validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,10 @@ var default_normalize_email_options = {
// Removes the subaddress (e.g. "-foo") from the email address
yahoo_remove_subaddress: true,

// The following conversions are specific to Yandex
// Lowercases the local part of the Yandex address (known to be case-insensitive)
yandex_lowercase: true,

// The following conversions are specific to iCloud
// Lowercases the local part of the iCloud address (known to be case-insensitive)
icloud_lowercase: true,
Expand Down Expand Up @@ -1537,7 +1541,7 @@ function normalizeEmail(email, options) {
parts[0] = parts[0].toLowerCase();
}
} else if (~yandex_domains.indexOf(parts[1])) {
if (options.all_lowercase || options.yahoo_lowercase) {
if (options.all_lowercase || options.yandex_lowercase) {
parts[0] = parts[0].toLowerCase();
}
parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
Expand Down
Loading

0 comments on commit 3cd87cb

Please sign in to comment.