Skip to content

Commit d78ba81

Browse files
committed
Remove duplicate .com strings
1 parent b17d33b commit d78ba81

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ CHANGELOG
1717
their local part when `hashAddress` is used. For example,
1818
`[email protected]` will become `[email protected]` for additional
1919
`yahoo.com` domains.
20+
* Duplicate `.com`s are now removed from email domain names when
21+
`hashAddress` is used. For example, `example.com.com` will become
22+
`example.com`.
2023

2124
6.0.0 (2023-12-05)
2225
------------------

src/request/email.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ describe('Email()', () => {
173173
md5: md5('[email protected]'),
174174
domain: 'ymail.com',
175175
},
176+
{
177+
178+
md5: md5('[email protected]'),
179+
domain: 'example.com.com',
180+
},
176181
];
177182

178183
test.each(normalizeTests)('%p', (arg) => {

src/request/email.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ export default class Email implements EmailProps {
314314

315315
domain = punycode.toASCII(domain);
316316

317+
domain = domain.replace(/(?:\.com){2,}$/, '.com');
318+
317319
if (Object.prototype.hasOwnProperty.call(Email.typoDomains, domain)) {
318320
domain = Email.typoDomains[domain];
319321
}

0 commit comments

Comments
 (0)