Class: Addressable::URI

Inherits:
Object
  • Object
show all
Defined in:
lib/postrank-uri.rb

Instance Method Summary collapse

Instance Method Details

#domainObject



10
11
12
13
# File 'lib/postrank-uri.rb', line 10

def domain
  host = self.host
  (host && PublicSuffix.valid?(host, default_rule: nil)) ? PublicSuffix.parse(host).domain : nil
end

#normalized_queryObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/postrank-uri.rb', line 15

def normalized_query
  @normalized_query ||= (begin
    if self.query && self.query.strip != ''
      (self.query.strip.split("&", -1).map do |pair|
        Addressable::URI.normalize_component(
          pair,
          Addressable::URI::CharacterClasses::QUERY.sub("\\&", "")
        )
      end).join("&")
    else
      nil
    end
  end)
end