From ba1c685d8cb12a1ac7079c1c629e0a8481c631d1 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 11 Jun 2014 15:30:12 -0700 Subject: only look up the subdomain once --- actionpack/lib/action_dispatch/http/url.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'actionpack') 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)) -- cgit v1.2.3