1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

only look up the subdomain once

This commit is contained in:
Aaron Patterson 2014-06-11 15:30:12 -07:00
parent 3327dd462f
commit ba1c685d8c

View file

@ -122,12 +122,13 @@ module ActionDispatch
tld_length = options[:tld_length] || @@tld_length tld_length = options[:tld_length] || @@tld_length
host = "" host = ""
if options[:subdomain] == true || !options.key?(:subdomain) subdomain = options[:subdomain]
if subdomain == true || !options.key?(:subdomain)
return _host if options[:domain].nil? 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? elsif subdomain
host << options[:subdomain].to_param host << subdomain.to_param
end end
host << "." unless host.empty? host << "." unless host.empty?
host << (options[:domain] || extract_domain(_host, tld_length)) host << (options[:domain] || extract_domain(_host, tld_length))