Skip to content

Commit 06d5827

Browse files
committed
Normalize equivalent domain names
1 parent e9d72f1 commit 06d5827

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v2.5.0
4+
5+
* Equivalent domain names are now normalized when `hash_address` is used.
6+
For example, `googlemail.com` will become `gmail.com`.
7+
38
## v2.4.0 (2024-01-12)
49

510
* Ruby 2.7+ is now required. If you're using Ruby 2.5 or 2.6, please use

lib/minfraud/components/email.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ def clean_email_address(address)
113113
}.freeze
114114
private_constant :TYPO_DOMAINS
115115

116+
EQUIVALENT_DOMAINS = {
117+
'googlemail.com' => 'gmail.com',
118+
'pm.me' => 'protonmail.com',
119+
'proton.me' => 'protonmail.com',
120+
'yandex.by' => 'yandex.ru',
121+
'yandex.com' => 'yandex.ru',
122+
'yandex.kz' => 'yandex.ru',
123+
'yandex.ua' => 'yandex.ru',
124+
'ya.ru' => 'yandex.ru',
125+
}.freeze
126+
private_constant :EQUIVALENT_DOMAINS
127+
116128
def clean_domain(domain)
117129
domain = domain.strip
118130

@@ -125,6 +137,10 @@ def clean_domain(domain)
125137
domain = TYPO_DOMAINS[domain]
126138
end
127139

140+
if EQUIVALENT_DOMAINS.key?(domain)
141+
domain = EQUIVALENT_DOMAINS[domain]
142+
end
143+
128144
domain
129145
end
130146
end

spec/components/email_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
{ input: '[email protected]', output: '[email protected]' },
7272
{ input: '[email protected]', output: '[email protected]' },
7373
{ input: 'Test+alias@bücher.com', output: '[email protected]' },
74+
{ input: '[email protected]', output: '[email protected]' },
7475
]
7576

7677
tests.each do |i|

0 commit comments

Comments
 (0)