Module: PslDomainExtractor

Defined in:
lib/psl-domain-extractor.rb,
lib/psl-domain-extractor/version.rb,
lib/psl-domain-extractor/extractors.rb,
lib/psl-domain-extractor/public_suffix_list.rb

Defined Under Namespace

Classes: Extractors, PublicSuffixList

Constant Summary collapse

VERSION =
"1.0.0".freeze

Class Method Summary collapse

Class Method Details

.domain_from(host, _tld_length = nil) ⇒ Object

These two methods allow this class to be used with Rails as the domain extractor for ActionDispatch. Add the following to your Rails configuration:

config.action_dispatch.domain_extractor = PslDomainExtractor


25
26
27
# File 'lib/psl-domain-extractor.rb', line 25

def self.domain_from(host, _tld_length = nil)
  extract_domain(host)
end

.extract_domain(domain) ⇒ Object



5
6
7
8
# File 'lib/psl-domain-extractor.rb', line 5

def self.extract_domain(domain)
  rules = rules_from_psl_file
  Extractors.new(rules).extract_domain(domain)
end

.extract_public_suffix(domain) ⇒ Object



15
16
17
18
# File 'lib/psl-domain-extractor.rb', line 15

def self.extract_public_suffix(domain)
  rules = rules_from_psl_file
  Extractors.new(rules).extract_public_suffix(domain)
end

.extract_subdomain(domain) ⇒ Object



10
11
12
13
# File 'lib/psl-domain-extractor.rb', line 10

def self.extract_subdomain(domain)
  rules = rules_from_psl_file
  Extractors.new(rules).extract_subdomain(domain)
end

.subdomains_from(host, _tld_length = nil) ⇒ Object



29
30
31
# File 'lib/psl-domain-extractor.rb', line 29

def self.subdomains_from(host, _tld_length = nil)
  extract_subdomain(host)
end