Sha256: dc1a8578ebc77bb0dc3c90ed34b5a53357821ea880800e4ee6ef00bf75d44850

Contents?: true

Size: 450 Bytes

Versions: 2

Compression:

Stored size: 450 Bytes

Contents

# frozen_string_literal: true

module Validators
  class TLD
    def self.all
      @all ||=
        begin
          Validators.require_dependency! "email_data"
          EmailData.tlds
        end
    end

    def self.host_with_valid_tld?(host)
      host = host.to_s

      return false if host.split(".").size == 1

      include?(host[/\.([^.]+)$/, 1].to_s.downcase)
    end

    def self.include?(tld)
      all.include?(tld)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
validators-3.4.2 lib/validators/tld.rb
validators-3.4.1 lib/validators/tld.rb