module ActionDispatch::Http::URL
def extract_domain(host, tld_length)
# Second-level domain example
extract_domain('www.example.com', 1) # => "example.com"
# Top-level domain example
Returns the domain part of a host given the domain level.
def extract_domain(host, tld_length) extract_domain_from(host, tld_length) if named_host?(host) end