diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-12 10:01:35 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-12 10:01:35 -0700 |
commit | 21c626133adc4b5060df1081d9423024b6b7479d (patch) | |
tree | 8ab8feff9de8b76f35b06bf36c44768df5f2885e /actionpack/lib | |
parent | caf1bfccc680510b48e058d40c2a99cae965b5cb (diff) | |
download | rails-21c626133adc4b5060df1081d9423024b6b7479d.tar.gz rails-21c626133adc4b5060df1081d9423024b6b7479d.tar.bz2 rails-21c626133adc4b5060df1081d9423024b6b7479d.zip |
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.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 8 |
1 files changed, 6 insertions, 2 deletions
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 |