From 21c626133adc4b5060df1081d9423024b6b7479d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 12 Jun 2014 10:01:35 -0700 Subject: reduce calls to `named_host?` `normalize_host` already calls `named_host?`, so there is no reason to test `named_host?` again in the `extract_domain` method. --- actionpack/lib/action_dispatch/http/url.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 92aba01b95..fd310d5219 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -13,7 +13,7 @@ module ActionDispatch class << self def extract_domain(host, tld_length) - host.split('.').last(1 + tld_length).join('.') if named_host?(host) + extract_domain_from(host, tld_length) if named_host?(host) end def extract_subdomains(host, tld_length) @@ -60,6 +60,10 @@ module ActionDispatch private + def extract_domain_from(host, tld_length) + host.split('.').last(1 + tld_length).join('.') + end + def add_trailing_slash(path) # includes querysting if path.include?('?') @@ -131,7 +135,7 @@ module ActionDispatch host << subdomain.to_param end host << "." unless host.empty? - host << (options[:domain] || extract_domain(_host, tld_length)) + host << (options[:domain] || extract_domain_from(_host, tld_length)) host end -- cgit v1.2.3