aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-11-23 10:05:47 +0100
committerJosé Valim <jose.valim@gmail.com>2010-11-23 10:05:47 +0100
commit56b12140246303440da18c0c5ea139b3b17b0282 (patch)
tree16b5c8de6233936b8f4cdfeffd6427a575fdf76c /actionpack
parent2fe43b694f36ddb2062a91eebe61a035147265b1 (diff)
downloadrails-56b12140246303440da18c0c5ea139b3b17b0282.tar.gz
rails-56b12140246303440da18c0c5ea139b3b17b0282.tar.bz2
rails-56b12140246303440da18c0c5ea139b3b17b0282.zip
Speed up subdomain and domain calculus.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb20
1 files changed, 6 insertions, 14 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index d823fd710e..ebced9cabe 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -570,22 +570,14 @@ module ActionDispatch
end
def subdomain_and_domain(options)
+ return nil unless options[:subdomain] || options[:domain]
tld_length = options[:tld_length] || ActionDispatch::Http::URL.tld_length
- current_domain = ActionDispatch::Http::URL.extract_domain(options[:host], tld_length)
- current_subdomain = ActionDispatch::Http::URL.extract_subdomain(options[:host], tld_length)
-
- domain_parts = if options[:subdomain] && options[:domain]
- [options[:subdomain], options[:domain]]
- elsif options[:subdomain]
- [options[:subdomain], current_domain]
- elsif options[:domain]
- [current_subdomain, options[:domain]]
- else
- nil
- end
-
- domain_parts ? domain_parts.join('.') : nil
+ host = ""
+ host << (options[:subdomain] || ActionDispatch::Http::URL.extract_subdomain(options[:host], tld_length))
+ host << "."
+ host << (options[:domain] || ActionDispatch::Http::URL.extract_domain(options[:host], tld_length))
+ host
end
def handle_positional_args(options)