Permalink
Browse files

only look up the subdomain once

  • Loading branch information...
1 parent 3327dd4 commit ba1c685d8cb12a1ac7079c1c629e0a8481c631d1 @tenderlove tenderlove committed Jun 11, 2014
Showing with 4 additions and 3 deletions.
  1. +4 −3 actionpack/lib/action_dispatch/http/url.rb
@@ -122,12 +122,13 @@ def normalize_host(_host, options)
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))

0 comments on commit ba1c685

Please sign in to comment.