diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-11 15:30:12 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-11 15:30:12 -0700 |
commit | ba1c685d8cb12a1ac7079c1c629e0a8481c631d1 (patch) | |
tree | fdf2a30ab7ce6812e660cfb03fa4fa8dfde1f210 /actionpack/lib/action_dispatch/http | |
parent | 3327dd462ffa28a197ece51443e603f24c14ddc6 (diff) | |
download | rails-ba1c685d8cb12a1ac7079c1c629e0a8481c631d1.tar.gz rails-ba1c685d8cb12a1ac7079c1c629e0a8481c631d1.tar.bz2 rails-ba1c685d8cb12a1ac7079c1c629e0a8481c631d1.zip |
only look up the subdomain once
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index b63c99d46f..6c2489ebb4 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -122,12 +122,13 @@ module ActionDispatch tld_length = options[:tld_length] || @@tld_length host = "" - if options[:subdomain] == true || !options.key?(:subdomain) + subdomain = options[:subdomain] + if subdomain == true || !options.key?(:subdomain) return _host if options[:domain].nil? host << extract_subdomain(_host, tld_length).to_param - elsif options[:subdomain].present? - host << options[:subdomain].to_param + elsif subdomain + host << subdomain.to_param end host << "." unless host.empty? host << (options[:domain] || extract_domain(_host, tld_length)) |