Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make prohibited_domain_characters_regex changeable #157

Merged
merged 2 commits into from
Aug 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/valid_email2/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ class Address
DEFAULT_RECIPIENT_DELIMITER = '+'.freeze
DOT_DELIMITER = '.'.freeze

def self.prohibited_domain_characters_regex
@prohibited_domain_characters_regex ||= PROHIBITED_DOMAIN_CHARACTERS_REGEX
end

def self.prohibited_domain_characters_regex=(val)
@prohibited_domain_characters_regex = val
end

def initialize(address)
@parse_error = false
@raw_address = address
Expand All @@ -30,7 +38,7 @@ def valid?
if address.domain && address.address == @raw_address
domain = address.domain

domain !~ PROHIBITED_DOMAIN_CHARACTERS_REGEX &&
domain !~ self.class.prohibited_domain_characters_regex &&
# Domain needs to have at least one dot
domain =~ /\./ &&
# Domain may not have two consecutive dots
Expand Down