Class: Twingly::PublicSuffixList

Inherits:
Object
  • Object
show all
Defined in:
lib/twingly/public_suffix_list.rb

Class Method Summary collapse

Class Method Details

.with_punycoded_names(encoding: Encoding::UTF_8) ⇒ Object

Extend the PSL with ASCII form of all internationalized domain names



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/twingly/public_suffix_list.rb', line 13

def self.with_punycoded_names(encoding: Encoding::UTF_8)
  list_path = PublicSuffix::List::DEFAULT_LIST_PATH
  list_data = File.read(list_path, encoding: encoding)
  list = PublicSuffix::List.parse(list_data, private_domains: false)

  punycoded_names(list).each do |punycoded_name|
    new_rule = PublicSuffix::Rule.factory(punycoded_name)
    list.add(new_rule)
  end

  list
end