Skip to content

Commit 4cf2c56

Browse files
committed
Remove extraneous characters after .com
1 parent 9c832ae commit 4cf2c56

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* Duplicate `.com`s are now removed from email domain names when
1818
`hash_address` is used. For example, `example.com.com` will become
1919
`example.com`.
20+
* Extraneous characters after `.com` are now removed from email domain
21+
names when `hash_address` is used. For example, `example.comfoo` will
22+
become `example.com`.
2023

2124
## v2.4.0 (2024-01-12)
2225

lib/minfraud/components/email.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ def clean_domain(domain)
327327
domain = SimpleIDN.to_ascii(domain)
328328

329329
domain.sub!(/(?:\.com){2,}$/, '.com')
330+
domain.sub!(/\.com[^.]+$/, '.com')
330331

331332
if TYPO_DOMAINS.key?(domain)
332333
domain = TYPO_DOMAINS[domain]

spec/components/email_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
{ input: ' [email protected]', output: '[email protected]' },
6464
{
6565
input: '[email protected]|abc124472372',
66-
output: '[email protected]|abc124472372',
66+
output: '[email protected]',
6767
},
6868
{ input: '[email protected]', output: '[email protected]' },
6969
{ input: '[email protected]', output: '[email protected]' },
@@ -76,6 +76,7 @@
7676
{ input: '[email protected]', output: '[email protected]' },
7777
{ input: '[email protected]', output: '[email protected]' },
7878
{ input: '[email protected]', output: '[email protected]' },
79+
{ input: '[email protected]', output: '[email protected]' },
7980
]
8081

8182
tests.each do |i|

0 commit comments

Comments
 (0)