aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-06-12 11:22:38 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-06-12 11:22:38 -0700
commitd7f780c30438ac563cd170080ed6e8f434256855 (patch)
treee912425229510d428eb5968e416c8287d7aa7b46 /actionpack
parent977a2f38c75368d6f086517b03f48f7bde19bf79 (diff)
downloadrails-d7f780c30438ac563cd170080ed6e8f434256855.tar.gz
rails-d7f780c30438ac563cd170080ed6e8f434256855.tar.bz2
rails-d7f780c30438ac563cd170080ed6e8f434256855.zip
only check named_host? once in normalize_host
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb
index 87e76113d6..a5858758c6 100644
--- a/actionpack/lib/action_dispatch/http/url.rb
+++ b/actionpack/lib/action_dispatch/http/url.rb
@@ -18,8 +18,7 @@ module ActionDispatch
def extract_subdomains(host, tld_length)
if named_host?(host)
- parts = host.split('.')
- parts[0..-(tld_length + 2)]
+ extract_subdomains_from(host, tld_length)
else
[]
end
@@ -64,6 +63,11 @@ module ActionDispatch
host.split('.').last(1 + tld_length).join('.')
end
+ def extract_subdomains_from(host, tld_length)
+ parts = host.split('.')
+ parts[0..-(tld_length + 2)]
+ end
+
def add_trailing_slash(path)
# includes querysting
if path.include?('?')
@@ -131,7 +135,7 @@ module ActionDispatch
if subdomain == true
return _host if domain.nil?
- host << extract_subdomain(_host, tld_length)
+ host << extract_subdomains_from(_host, tld_length).join('.')
elsif subdomain
host << subdomain.to_param
end