Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Speed up subdomain and domain calculus.

  • Loading branch information...
commit 56b12140246303440da18c0c5ea139b3b17b0282 1 parent 2fe43b6
@josevalim josevalim authored
Showing with 6 additions and 14 deletions.
  1. +6 −14 actionpack/lib/action_dispatch/routing/route_set.rb
View
20 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -570,22 +570,14 @@ def host_from_options(options)
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)
Please sign in to comment.
Something went wrong with that request. Please try again.