Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/normalizeEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const default_normalize_email_options = {
// The following conversions are specific to Yandex
// Lowercases the local part of the Yandex address (known to be case-insensitive)
yandex_lowercase: true,
// all yandex domains are equal, this explicitly sets the domain to 'yandex.ru'
yandex_convert_yandexru: true,

// The following conversions are specific to iCloud
// Lowercases the local part of the iCloud address (known to be case-insensitive)
Expand Down Expand Up @@ -232,7 +234,7 @@ export default function normalizeEmail(email, options) {
if (options.all_lowercase || options.yandex_lowercase) {
parts[0] = parts[0].toLowerCase();
}
parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
parts[1] = options.yandex_convert_yandexru ? 'yandex.ru' : parts[1];
} else if (options.all_lowercase) {
// Any other address
parts[0] = parts[0].toLowerCase();
Expand Down
29 changes: 29 additions & 0 deletions test/sanitizers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,5 +481,34 @@ describe('Sanitizers', () => {
'[email protected]': '[email protected]',
},
});

// Testing yandex_convert_yandexru
test({
sanitizer: 'normalizeEmail',
args: [{
yandex_convert_yandexru: false,
}],
expect: {
'[email protected]': '[email protected]',
'[email protected]': '[email protected]',
'[email protected]': '[email protected]',
'[email protected]': '[email protected]',
'[email protected]': '[email protected]',
},
});

test({
sanitizer: 'normalizeEmail',
args: [{
yandex_convert_yandexru: true,
}],
expect: {
'[email protected]': '[email protected]',
'[email protected]': '[email protected]',
'[email protected]': '[email protected]',
'[email protected]': '[email protected]',
'[email protected]': '[email protected]',
},
});
});
});