Skip to content

Commit

Permalink
Fixes #40 when email in is nil, output nil as well
Browse files Browse the repository at this point in the history
  • Loading branch information
afair committed Nov 21, 2019
1 parent e85f558 commit 8b2f5e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/email_address/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class Address
# address. The original string is available in the #original method.
def initialize(email_address, config={})
@config = config # This needs refactoring!
email_address = (email_address || "").strip
@original = email_address
email_address = (email_address || "").strip
email_address = parse_rewritten(email_address) unless config[:skip_rewrite]
local, host = EmailAddress::Address.split_local_host(email_address)

Expand Down
4 changes: 4 additions & 0 deletions test/email_address/test_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,8 @@ def test_relaxed_normal
assert ! EmailAddress.new('[email protected]').valid?
assert true, EmailAddress.new('[email protected]', local_format: :relaxed).valid?
end

def test_nil_address
assert_nil EmailAddress.new(nil).normal, "Expected a nil input to make nil output"
end
end

0 comments on commit 8b2f5e7

Please sign in to comment.