Skip to content

Commit ba1c685

Browse files
committed
only look up the subdomain once
1 parent 3327dd4 commit ba1c685

File tree

1 file changed

+4
-3
lines changed
  • actionpack/lib/action_dispatch/http

1 file changed

+4
-3
lines changed

actionpack/lib/action_dispatch/http/url.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,13 @@ def normalize_host(_host, options)
122122
tld_length = options[:tld_length] || @@tld_length
123123

124124
host = ""
125-
if options[:subdomain] == true || !options.key?(:subdomain)
125+
subdomain = options[:subdomain]
126+
if subdomain == true || !options.key?(:subdomain)
126127
return _host if options[:domain].nil?
127128

128129
host << extract_subdomain(_host, tld_length).to_param
129-
elsif options[:subdomain].present?
130-
host << options[:subdomain].to_param
130+
elsif subdomain
131+
host << subdomain.to_param
131132
end
132133
host << "." unless host.empty?
133134
host << (options[:domain] || extract_domain(_host, tld_length))

0 commit comments

Comments
 (0)