Skip to content

Commit 8c1dde1

Browse files
committed
Remove extraneous characters after .com
1 parent d78ba81 commit 8c1dde1

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ CHANGELOG
2020
* Duplicate `.com`s are now removed from email domain names when
2121
`hashAddress` is used. For example, `example.com.com` will become
2222
`example.com`.
23+
* Extraneous characters after `.com` are now removed from email domain
24+
names when `hashAddress` is used. For example, `example.comfoo` will
25+
become `example.com`.
2326

2427
6.0.0 (2023-12-05)
2528
------------------

src/request/email.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ describe('Email()', () => {
178178
md5: md5('[email protected]'),
179179
domain: 'example.com.com',
180180
},
181+
{
182+
183+
md5: md5('[email protected]'),
184+
domain: 'example.comfoo',
185+
},
181186
];
182187

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

src/request/email.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ export default class Email implements EmailProps {
315315
domain = punycode.toASCII(domain);
316316

317317
domain = domain.replace(/(?:\.com){2,}$/, '.com');
318+
domain = domain.replace(/\.com[^.]+$/, '.com');
318319

319320
if (Object.prototype.hasOwnProperty.call(Email.typoDomains, domain)) {
320321
domain = Email.typoDomains[domain];

0 commit comments

Comments
 (0)