email_repair 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ee85877aa4e7df7d05e7084df4553209c6de6f4d555fe16ddd13070628f5ca5
4
- data.tar.gz: e1ace67bbe8264421ae9c73dd77a7dde04097d694a90fcfae608b21e49d8e3be
3
+ metadata.gz: 105137fd47de14a0ff9abb61245e332307302acddb760a537e6ab284a042ca1b
4
+ data.tar.gz: e5286f3eb0a792a1c3492eff0b29eb65b0456979fd2e7066cecab6de37b1ca0e
5
5
  SHA512:
6
- metadata.gz: 58d21040563feed012c9218fb37f94173b895718ba103ff7d626e4dc3edb9c3c2c76f1f4395462522045b8eb88ad2ba393c81e995e709daaf663657a617c6e17
7
- data.tar.gz: 66a4f543f9db2cf547dacfdb4eed8d55d1e9a98a9d6a9b7a2d5ca3ad9461769857458ccf18f02ff3faedc9b508634e0b36e4db13e681ea6f3444786d0fa133fe
6
+ metadata.gz: cdb2c7e2e99c6141050d3081b3ca7cd1864b9f81fc1f51616de271e5bd669295d8937e183899541179cf5766edc5f573cb8a84ca585bc864dbf6c6060197b977
7
+ data.tar.gz: 400e9eae791a4c1a1271f3472f28a4d3c7e5f7144530f9b66df786910db241d1e94bf6807b43ce0ac2da6b6b072f1f1fde78161cd54c889c933c6f84927074f0
@@ -96,8 +96,11 @@ module EmailRepair
96
96
 
97
97
  class CommonDomainAtAdder < CommonDomainRepair
98
98
  def self.repair(email)
99
+ return email if email.match('.+@.+\..+')
100
+
99
101
  common_domains.each do |name, suffix|
100
102
  punc_regex = /[.#-]#{name}.#{suffix}$/
103
+
101
104
  if email.match(punc_regex)
102
105
  email = email.sub(punc_regex, "@#{name}.#{suffix}")
103
106
  elsif email.match?(/[^@]#{name}.#{suffix}$/)
@@ -112,8 +115,8 @@ module EmailRepair
112
115
  def self.repair(email)
113
116
  swapped_names.each do |swapped, real|
114
117
  suffix = common_domains[real]
115
- regex = /#{swapped}.#{suffix}$/
116
- email = email.sub(regex, "#{real}.#{suffix}") if email.match(regex)
118
+ regex = /@#{swapped}.#{suffix}$/
119
+ email = email.sub(regex, "@#{real}.#{suffix}") if email.match(regex)
117
120
  end
118
121
  email
119
122
  end
@@ -1,3 +1,3 @@
1
1
  module EmailRepair
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
data/lib/email_repair.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'ostruct'
1
2
  require 'email_repair/constants'
2
3
  require 'email_repair/mechanic'
3
4
  require 'email_repair/version'
@@ -109,6 +109,11 @@ module EmailRepair
109
109
  end
110
110
  end
111
111
 
112
+ it 'does not sanitize when common domain is part of the domain' do
113
+ email = 'me@goal.com'
114
+ expect(mechanic.repair(email)).to eq email
115
+ end
116
+
112
117
  it 'swaps a # for an @ for common domains' do
113
118
  expect(mechanic.repair('pound#yahoo.com')).to eq 'pound@yahoo.com'
114
119
  end
@@ -123,6 +128,10 @@ module EmailRepair
123
128
  end
124
129
  end
125
130
 
131
+ it 'does not add an extra @ if there is already one' do
132
+ expect(mechanic.repair('bloo@myyahoo.com')).to eq 'bloo@myyahoo.com'
133
+ end
134
+
126
135
  it 'replaces , with .' do
127
136
  expect(mechanic.repair('b@b,com')).to eq 'b@b.com'
128
137
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_repair
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Holman Gao
8
8
  - JT Bowler
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2023-05-01 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: coveralls
@@ -67,7 +66,6 @@ dependencies:
67
66
  - - "~>"
68
67
  - !ruby/object:Gem::Version
69
68
  version: 1.50.2
70
- description:
71
69
  email:
72
70
  - holman@golmansax.com
73
71
  - jbowler2400@gmail.com
@@ -88,7 +86,6 @@ homepage: https://github.com/ChalkSchools/email-repair
88
86
  licenses:
89
87
  - MIT
90
88
  metadata: {}
91
- post_install_message:
92
89
  rdoc_options: []
93
90
  require_paths:
94
91
  - lib
@@ -103,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
100
  - !ruby/object:Gem::Version
104
101
  version: '0'
105
102
  requirements: []
106
- rubygems_version: 3.4.2
107
- signing_key:
103
+ rubygems_version: 3.6.9
108
104
  specification_version: 4
109
105
  summary: Library to fix invalid emails
110
106
  test_files: