Module: ValidatesHostname::Tld
- Defined in:
- lib/validates_hostname.rb
Overview
Handles TLD list loading and management.
Constant Summary collapse
- ALLOWED_TLDS =
load_tlds
Class Method Summary collapse
Class Method Details
.load_tlds ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/validates_hostname.rb', line 12 def self.load_tlds tlds_file_path = File.('../data/tlds.txt', __dir__) Set.new(File.readlines(tlds_file_path) .map(&:strip) .map(&:downcase) .reject { |line| line.start_with?('#') || line.empty? }) .add('.') .freeze end |