Skip to content

Commit

Permalink
Merge pull request #1097 from alphagov/add-additional-domain-autocorr…
Browse files Browse the repository at this point in the history
…ections

Add additional corrections for '.c.uk' typos
  • Loading branch information
pixeltrix authored Dec 9, 2024
2 parents ade4f49 + 17c0152 commit bd51118
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/domain_autocorrect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ class DomainAutocorrect
/\A([^@]+)@((?:f|g)\.?(?:a|m|n)(?:a|i|m|n|s)(?:a|i|l|o|u)(?:i|k|l){0,2}\.(?:cim|clm|comm|com\.uk|com\.com|com|con|vom|cm|co\.uk|co|om|uk))\z/ => 'gmail.com',
/\A([^@]+)@(goog?le?m(?:a|i|s)(?:a|i)l\.(?:com|con|co\.uk))\z/ => 'googlemail.com',
/\A([^@]+)@(h(?:i|o)(?:r|t)?(?:m|n)(?:a|i|s)?(?:a|i|u)?(?:k|l){0,2}\.(?:cim|com|con|cm|co))\z/ => 'hotmail.com',
/\A([^@]+)@(h(?:i|o)(?:r|t)?(?:m|n)(?:a|i|s)?(?:a|i|u)?(?:k|l){0,2}\.?(?:com|con|co)?\.?(?:ik|uk|uj|ul|um|un|yk))\z/ => 'hotmail.co.uk',
/\A([^@]+)@(h(?:i|o)(?:r|t)?(?:m|n)(?:a|i|s)?(?:a|i|u)?(?:k|l){0,2}\.?(?:com|con|co|c)?\.?(?:ik|uk|uj|ul|um|un|yk))\z/ => 'hotmail.co.uk',
/\A([^@]+)@(i?(?:c|v)l?oul?d\.(?:com|con|co\.uk))\z/ => 'icloud.com',
/\A([^@]+)@(live\.(?:com|con|co))\z/ => 'live.com',
/\A([^@]+)@(live\.co\.(?:ik|uk|um|un))\z/ => 'live.co.uk',
/\A([^@]+)@(live\.(?:co|c)\.(?:ik|uk|um|un))\z/ => 'live.co.uk',
/\A([^@]+)@(mac\.(?:com|con))\z/ => 'mac.com',
/\A([^@]+)@(me\.(?:com|con))\z/ => 'me.com',
/\A([^@]+)@(msn\.(?:com|con))\z/ => 'msn.com',
/\A([^@]+)@(ntlworl?d\.(?:com|con))\z/ => 'ntlworld.com',
/\A([^@]+)@(out?l?(?:i|o)o+k\.co(?:m|n|\.uk))\z/ => 'outlook.com',
/\A([^@]+)@(sky\.co(?:m|n))\z/ => 'sky.com',
/\A([^@]+)@(talktalk\.(?:com|net))\z/ => 'talktalk.net',
/\A([^@]+)@((?:u|t|y)(?:a|s)?hoo?\.?(?:co)?n?\.?(?:i|u|y)(?:j|k|l|m|n))\z/ => 'yahoo.co.uk',
/\A([^@]+)@((?:u|t|y)(?:a|s)?hoo?\.?(?:com|con|co|c)?\.?(?:i|u|y)(?:j|k|l|m|n))\z/ => 'yahoo.co.uk',
/\A([^@]+)@(yahoo\.co(?:m|n)?)\z/ => 'yahoo.com'
}

Expand Down
13 changes: 10 additions & 3 deletions spec/lib/domain_autocorrect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
hormail.co.uk
hotmai.co.uk
hotmaik.co.uk
hotmail.c.uk
hotmail.co.ik
hotmail.co.uj
hotmail.co.ul
Expand All @@ -193,8 +194,8 @@
hotmailco.uk
hotmal.co.uk
hotmaul.co.uk
hotmil.co.uk
hotmial.co.uk
hotmil.co.uk
hotmsil.co.uk
hotnail.co.uk
].each do |domain|
Expand Down Expand Up @@ -252,7 +253,12 @@
).to eq("[email protected]")
end

%w[live.co.ik live.co.um live.co.un].each do |domain|
%w[
live.c.uk
live.co.ik
live.co.um
live.co.un
].each do |domain|
it "autocorrects '#{domain}' to 'live.co.uk'" do
expect(
described_class.call("bob.jones@#{domain}")
Expand Down Expand Up @@ -404,12 +410,13 @@
end

%w[
yahoo.co.uk
tahoo.co.uk
uahoo.co.uk
yaho.co.uk
yahoo.c.uk
yahoo.co.ik
yahoo.co.uj
yahoo.co.uk
yahoo.co.ul
yahoo.co.um
yahoo.co.un
Expand Down

0 comments on commit bd51118

Please sign in to comment.