sources: factor out Source::URL::ArtStation.
This commit is contained in:
@@ -10,7 +10,7 @@ module Danbooru
|
||||
# @return [Addressable:URI] The parsed and normalized URL.
|
||||
attr_reader :url
|
||||
|
||||
delegate :domain, :host, :site, :path, to: :url
|
||||
delegate :domain, :host, :site, :path, :query, to: :url
|
||||
|
||||
# Parse a string into a URL, or raise an exception if the string is not a valid HTTPS or HTTPS URL.
|
||||
#
|
||||
@@ -62,5 +62,18 @@ module Danbooru
|
||||
def params
|
||||
url.query_values.to_h.with_indifferent_access
|
||||
end
|
||||
|
||||
# Return the subdomain of the URL, or nil if absent. For example, for "http://senpenbankashiki.hp.infoseek.co.jp", the
|
||||
# subdomain is "senpenbankashiki.hp", the domain is "infoseek.co.jp", the SLD is "infoseek", and the TLD is "co.jp".
|
||||
#
|
||||
# @return [String, nil]
|
||||
def subdomain
|
||||
parsed_domain.trd
|
||||
end
|
||||
|
||||
# @return [PublicSuffix::Domain]
|
||||
def parsed_domain
|
||||
@parsed_domain ||= PublicSuffix.parse(host)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user