diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-12 11:22:38 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-12 11:22:38 -0700 |
commit | d7f780c30438ac563cd170080ed6e8f434256855 (patch) | |
tree | e912425229510d428eb5968e416c8287d7aa7b46 /actionpack/lib/action_dispatch | |
parent | 977a2f38c75368d6f086517b03f48f7bde19bf79 (diff) | |
download | rails-d7f780c30438ac563cd170080ed6e8f434256855.tar.gz rails-d7f780c30438ac563cd170080ed6e8f434256855.tar.bz2 rails-d7f780c30438ac563cd170080ed6e8f434256855.zip |
only check named_host? once in normalize_host
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 10 |
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 |