Sha256: 126f892f9a7b9ccbae7e4bf3c466b5b1a55c34281eb72aee9a0cf30706a15d92
Contents?: true
Size: 854 Bytes
Versions: 9
Compression:
Stored size: 854 Bytes
Contents
# frozen_string_literal: true require "email_assessor/email_validator" module EmailAssessor DISPOSABLE_DOMAINS_FILE_NAME = File.expand_path("../../vendor/disposable_domains.txt", __FILE__) BLACKLISTED_DOMAINS_FILE_NAME = File.expand_path("vendor/blacklisted_domains.txt") def self.domain_is_disposable?(domain) domain_in_file?(domain, DISPOSABLE_DOMAINS_FILE_NAME) end def self.domain_is_blacklisted?(domain) domain_in_file?(domain, BLACKLISTED_DOMAINS_FILE_NAME) end protected def self.domain_in_file?(domain, file_name) file_name ||= "" domain = domain.downcase # Using String#end_with? here would lead to unexpected quirks and false positives. # For instance, hotmail.com is valid but tmail.com is not. File.foreach(file_name).any? { |line| domain.match?(%r{\A(?:.+\.)*?#{line.chomp}\z}i) } end end
Version data entries
9 entries across 9 versions & 1 rubygems