Skip to content

Commit f2b1082

Browse files
authored
fix: hard coded yandex domain conversion (#2441)
1 parent 72c4674 commit f2b1082

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/lib/normalizeEmail.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const default_normalize_email_options = {
3232
// The following conversions are specific to Yandex
3333
// Lowercases the local part of the Yandex address (known to be case-insensitive)
3434
yandex_lowercase: true,
35+
// all yandex domains are equal, this explicitly sets the domain to 'yandex.ru'
36+
yandex_convert_yandexru: true,
3537

3638
// The following conversions are specific to iCloud
3739
// Lowercases the local part of the iCloud address (known to be case-insensitive)
@@ -232,7 +234,7 @@ export default function normalizeEmail(email, options) {
232234
if (options.all_lowercase || options.yandex_lowercase) {
233235
parts[0] = parts[0].toLowerCase();
234236
}
235-
parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
237+
parts[1] = options.yandex_convert_yandexru ? 'yandex.ru' : parts[1];
236238
} else if (options.all_lowercase) {
237239
// Any other address
238240
parts[0] = parts[0].toLowerCase();

test/sanitizers.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,5 +481,34 @@ describe('Sanitizers', () => {
481481
482482
},
483483
});
484+
485+
// Testing yandex_convert_yandexru
486+
test({
487+
sanitizer: 'normalizeEmail',
488+
args: [{
489+
yandex_convert_yandexru: false,
490+
}],
491+
expect: {
492+
493+
494+
495+
496+
497+
},
498+
});
499+
500+
test({
501+
sanitizer: 'normalizeEmail',
502+
args: [{
503+
yandex_convert_yandexru: true,
504+
}],
505+
expect: {
506+
507+
508+
509+
510+
511+
},
512+
});
484513
});
485514
});

0 commit comments

Comments
 (0)