Method: ActionDispatch::Http::URL#domain
- Defined in:
- lib/action_dispatch/http/url.rb
#domain(tld_length = 1) ⇒ Object
Returns the domain part of a host, such as “rubyonrails.org” in “www.rubyonrails.org”. You can specify a different tld_length, such as 2 to catch rubyonrails.co.uk in “www.rubyonrails.co.uk”.
78 79 80 81 82 |
# File 'lib/action_dispatch/http/url.rb', line 78 def domain(tld_length = 1) return nil unless named_host?(host) host.split('.').last(1 + tld_length).join('.') end |