From fef7a77386b0e738f3b5c25fd9ab0350a6e56d6c Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 28 Feb 2010 17:16:34 -0600 Subject: [PATCH] Request#subdomain returns a string version of Request#subdomains --- actionpack/lib/action_dispatch/http/url.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 40ceb5a9b6..42ad19044d 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -81,6 +81,10 @@ module ActionDispatch parts[0..-(tld_length+2)] end + def subdomain(tld_length = 1) + subdomains(tld_length).join('.') + end + # Returns the query string, accounting for server idiosyncrasies. def query_string @env['QUERY_STRING'].present? ? @env['QUERY_STRING'] : (@env['REQUEST_URI'].to_s.split('?', 2)[1] || '')