Upgrade mail gem to remove dependency on mime-types.
* Use a EmailValidator.email_regexp for `Email.is_valid?` check as we're seeing an increase in allocation when parsing email addresses wih `Mail::Address`.
This commit is contained in:
parent
51657d3426
commit
58b8ea4f41
1
Gemfile
1
Gemfile
|
@ -25,7 +25,6 @@ else
|
|||
end
|
||||
|
||||
gem 'mail'
|
||||
gem 'mime-types', require: 'mime/types/columnar'
|
||||
gem 'mini_mime'
|
||||
gem 'mini_suffix'
|
||||
|
||||
|
|
|
@ -163,16 +163,13 @@ GEM
|
|||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
lru_redux (1.1.0)
|
||||
mail (2.6.6)
|
||||
mime-types (>= 1.16, < 4)
|
||||
mail (2.7.0)
|
||||
mini_mime (>= 0.1.1)
|
||||
memory_profiler (0.9.10)
|
||||
message_bus (2.1.2)
|
||||
rack (>= 1.1.3)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_mime (0.1.3)
|
||||
mini_portile2 (2.3.0)
|
||||
mini_racer (0.1.15)
|
||||
|
@ -445,7 +442,6 @@ DEPENDENCIES
|
|||
mail
|
||||
memory_profiler
|
||||
message_bus
|
||||
mime-types
|
||||
mini_mime
|
||||
mini_racer
|
||||
mini_suffix
|
||||
|
|
11
lib/email.rb
11
lib/email.rb
|
@ -8,16 +8,7 @@ module Email
|
|||
|
||||
def self.is_valid?(email)
|
||||
return false unless String === email
|
||||
|
||||
parsed = Mail::Address.new(email)
|
||||
|
||||
# Don't allow for a TLD by itself list (sam@localhost)
|
||||
# The Grammar is: (local_part "@" domain) / local_part ... need to discard latter
|
||||
parsed.address == email &&
|
||||
parsed.local != parsed.address &&
|
||||
parsed&.domain.split(".").size > 1
|
||||
rescue Mail::Field::ParseError
|
||||
false
|
||||
!!(EmailValidator.email_regex =~ email)
|
||||
end
|
||||
|
||||
def self.downcase(email)
|
||||
|
|
Loading…
Reference in New Issue