diff options
-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 |