aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-02-28 17:16:34 -0600
committerJoshua Peek <josh@joshpeek.com>2010-02-28 17:16:34 -0600
commitfef7a77386b0e738f3b5c25fd9ab0350a6e56d6c (patch)
tree64c95282862dd2af417f43ec17dcdf545f9a8bee
parent7317d9ef4c1361219671dc4405a02ed3896f1742 (diff)
downloadrails-fef7a77386b0e738f3b5c25fd9ab0350a6e56d6c.tar.gz
rails-fef7a77386b0e738f3b5c25fd9ab0350a6e56d6c.tar.bz2
rails-fef7a77386b0e738f3b5c25fd9ab0350a6e56d6c.zip
Request#subdomain returns a string version of Request#subdomains
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb4
1 files changed, 4 insertions, 0 deletions
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] || '')