Sha256: b4a5472e698a7babb1cfc2570829a9b80ce21652a3e03b70796631ce517ff39d

Contents?: true

Size: 645 Bytes

Versions: 2

Compression:

Stored size: 645 Bytes

Contents

# frozen_string_literal: true

require "email_inquire/validator/base"

module EmailInquire
  module Validator
    class CommonlyMistakenTld < Base

      MISTAKES = {
        ".combr" => ".com.br",
        ".cojp" => ".co.jp",
        ".couk" => ".co.uk",
        ".com.com" => ".com",
      }.freeze

      def validate
        mistake, reference =
          MISTAKES.find do |mistake, reference|
            next if !mistake.end_with?(reference) && domain.end_with?(reference)

            domain.end_with?(mistake)
          end

        response.hint!(domain: domain.sub(/#{mistake}\z/, reference)) if reference
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
email_inquire-0.11.0 lib/email_inquire/validator/commonly_mistaken_tld.rb
email_inquire-0.10.0 lib/email_inquire/validator/commonly_mistaken_tld.rb