Skip to content

Commit ea95d39

Browse files
authored
Merge pull request #95 from maxmind/horgh/period
Remove all trailing periods from domains
2 parents 48dd576 + 61f3143 commit ea95d39

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
become `gmail.com`.
2525
* Additional `gmail.com` typos are now normalized when `hash_address` is
2626
used. For example, `gmali.com` will become `gmail.com`.
27+
* When `hash_address` is used, all trailing periods are now removed from an
28+
email address domain. Previously only a single period was removed.
2729

2830
## v2.4.0 (2024-01-12)
2931

lib/minfraud/components/email.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,7 @@ def clean_email_address(address)
373373
def clean_domain(domain)
374374
domain = domain.strip
375375

376-
# We could use delete_suffix!, but that is in Ruby 2.5+ only.
377-
domain.sub!(/\.\z/, '')
376+
domain.sub!(/\.+\z/, '')
378377

379378
domain = SimpleIDN.to_ascii(domain)
380379

spec/components/email_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
{ input: '[email protected]', output: '[email protected]' },
8181
{ input: '[email protected]', output: '[email protected]' },
8282
{ input: '[email protected]', output: '[email protected]' },
83+
{ input: '[email protected].', output: '[email protected]' },
84+
{ input: '[email protected]...', output: '[email protected]' },
8385
]
8486

8587
tests.each do |i|

0 commit comments

Comments
 (0)