Skip to content

Commit 9c832ae

Browse files
committed
Remove duplicate .com strings
1 parent 78939db commit 9c832ae

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
their local part when `hash_address` is used. For example,
1515
`[email protected]` will become `[email protected]` for additional
1616
`yahoo.com` domains.
17+
* Duplicate `.com`s are now removed from email domain names when
18+
`hash_address` is used. For example, `example.com.com` will become
19+
`example.com`.
1720

1821
## v2.4.0 (2024-01-12)
1922

lib/minfraud/components/email.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ def clean_domain(domain)
326326

327327
domain = SimpleIDN.to_ascii(domain)
328328

329+
domain.sub!(/(?:\.com){2,}$/, '.com')
330+
329331
if TYPO_DOMAINS.key?(domain)
330332
domain = TYPO_DOMAINS[domain]
331333
end

spec/components/email_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
{ input: '[email protected]', output: '[email protected]' },
7676
{ input: '[email protected]', output: '[email protected]' },
7777
{ input: '[email protected]', output: '[email protected]' },
78+
{ input: '[email protected]', output: '[email protected]' },
7879
]
7980

8081
tests.each do |i|

0 commit comments

Comments
 (0)