diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-11 14:05:04 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-11 14:05:04 -0700 |
commit | 3654f1b7e48c05e95fa7ea8f87ddfcfee12de771 (patch) | |
tree | 2417f62843fd7694260c2ac5e47be730b5189f7a /actionpack | |
parent | 79469b4b0c05a50e19699bc9b568042add2d4987 (diff) | |
download | rails-3654f1b7e48c05e95fa7ea8f87ddfcfee12de771.tar.gz rails-3654f1b7e48c05e95fa7ea8f87ddfcfee12de771.tar.bz2 rails-3654f1b7e48c05e95fa7ea8f87ddfcfee12de771.zip |
Revert "rm `same_host?`. The same conditional is two lines down."
This reverts commit 79469b4b0c05a50e19699bc9b568042add2d4987.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 1ee9f3c89e..6112ab2fd6 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -102,6 +102,10 @@ module ActionDispatch host && IP_HOST_REGEXP !~ host end + def same_host?(options) + (options[:subdomain] == true || !options.key?(:subdomain)) && options[:domain].nil? + end + def normalize_protocol(protocol) case protocol when nil @@ -116,16 +120,15 @@ module ActionDispatch end def normalize_host(_host, options) - return _host unless named_host?(_host) + return _host if !named_host?(_host) || same_host?(options) tld_length = options[:tld_length] || @@tld_length - host = nil + host = "" if options[:subdomain] == true || !options.key?(:subdomain) - return _host if options[:domain].nil? - host = extract_subdomain(_host, tld_length).to_param + host << extract_subdomain(_host, tld_length).to_param elsif options[:subdomain].present? - host = options[:subdomain].to_param + host << options[:subdomain].to_param end host << "." unless host.empty? host << (options[:domain] || extract_domain(_host, tld_length)) |