Method: ActionDispatch::Http::URL.extract_subdomain
- Defined in:
- actionpack/lib/action_dispatch/http/url.rb
.extract_subdomain(host, tld_length) ⇒ Object
Returns the subdomains of a host as a String given the domain level.
# Top-level domain example
extract_subdomain('www.example.com', 1) # => "www"
# Second-level domain example
extract_subdomain('dev.www.example.co.uk', 2) # => "dev.www"
48 49 50 |
# File 'actionpack/lib/action_dispatch/http/url.rb', line 48 def extract_subdomain(host, tld_length) extract_subdomains(host, tld_length).join(".") end |