Skip to content

Commit

Permalink
Merge pull request #55 from arcage/v0.4.6
Browse files Browse the repository at this point in the history
Fix email address validation.
  • Loading branch information
arcage authored Jan 10, 2020
2 parents 1506c2a + 42ff59f commit d4d82d8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: email
version: 0.4.5
version: 0.4.6

authors:
- ʕ·ᴥ·ʔAKJ <[email protected]>
Expand Down
5 changes: 5 additions & 0 deletions spec/email/address_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ describe EMail::Address do
EMail::Address.valid_address!("[email protected]").should eq "[email protected]"
end

it "accepts domain part without \".\"" do
EMail::Address.valid_address!("aa@localhost").should eq "aa@localhost"
end

it "raises Email::Error::AddressError when argument seems to be invalid as a email address" do
expect_raises(EMail::Error::AddressError) {
EMail::Address.valid_address!("aa@bb,cc")
}
end

end

describe ".valid_name!" do
Expand Down
2 changes: 1 addition & 1 deletion src/email.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require "uri"
require "./email/*"

module EMail
VERSION = "0.4.5"
VERSION = "0.4.6"
DEFAULT_SMTP_PORT = 25

# :nodoc:
Expand Down
2 changes: 1 addition & 1 deletion src/email/address.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class EMail::Address
getter name

# :nodoc:
ADDRESS_FORMAT = /\A[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`^{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`^{\|\}\~]+)*@[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`^{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`^{\|\}\~]+)+\z/
ADDRESS_FORMAT = /\A[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\^\{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\^\{\|\}\~]+)*@[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\^\{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\^\{\|\}\~]+)*\z/

# :nodoc:
NAME_FORMAT = /\A[a-zA-Z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~ \t]+\z/
Expand Down

0 comments on commit d4d82d8

Please sign in to comment.