Method: ActionDispatch::Http::URL.extract_subdomains
- Defined in:
- actionpack/lib/action_dispatch/http/url.rb
.extract_subdomains(host, tld_length) ⇒ Object
Returns the subdomains of a host as an Array given the domain level.
# Top-level domain example
extract_subdomains('www.example.com', 1) # => ["www"]
# Second-level domain example
extract_subdomains('dev.www.example.co.uk', 2) # => ["dev", "www"]
34 35 36 37 38 39 40 |
# File 'actionpack/lib/action_dispatch/http/url.rb', line 34 def extract_subdomains(host, tld_length) if named_host?(host) extract_subdomains_from(host, tld_length) else [] end end |