diff options
author | Kamil Sobieraj <ksobej@gmail.com> | 2011-10-04 09:16:34 +0100 |
---|---|---|
committer | Kamil Sobieraj <ksobej@gmail.com> | 2011-10-04 09:16:34 +0100 |
commit | de942e5534a26942e261a7699adc28597c5ad1bc (patch) | |
tree | c326ef6b47d71a763d7a635c5496dd99739af1c1 /actionpack/lib | |
parent | 1eac9119620e9b537c1eca9619d4fa3ecb546149 (diff) | |
download | rails-de942e5534a26942e261a7699adc28597c5ad1bc.tar.gz rails-de942e5534a26942e261a7699adc28597c5ad1bc.tar.bz2 rails-de942e5534a26942e261a7699adc28597c5ad1bc.zip |
:subdomain can now be specified with a value of false in url_for, allowing for subdomain(s) removal from the host during link generation. Closes #2025
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 8 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/url_for.rb | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index caa1decb9e..0db404957b 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -64,13 +64,15 @@ module ActionDispatch end def host_or_subdomain_and_domain(options) - return options[:host] unless options[:subdomain] || options[:domain] + return options[:host] unless options[:subdomain] || options[:subdomain] == false || options[:domain] tld_length = options[:tld_length] || @@tld_length host = "" - host << (options[:subdomain] || extract_subdomain(options[:host], tld_length)) - host << "." + unless options[:subdomain] == false + host << (options[:subdomain] || extract_subdomain(options[:host], tld_length)) + host << "." + end host << (options[:domain] || extract_domain(options[:host], tld_length)) host end diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb index 30048cd48a..8fc8dc191b 100644 --- a/actionpack/lib/action_dispatch/routing/url_for.rb +++ b/actionpack/lib/action_dispatch/routing/url_for.rb @@ -116,9 +116,10 @@ module ActionDispatch # If <tt>:only_path</tt> is false, this option must be # provided either explicitly, or via +default_url_options+. # * <tt>:subdomain</tt> - Specifies the subdomain of the link, using the +tld_length+ - # to split the domain from the host. - # * <tt>:domain</tt> - Specifies the domain of the link, using the +tld_length+ # to split the subdomain from the host. + # If false, removes all subdomains from the host part of the link. + # * <tt>:domain</tt> - Specifies the domain of the link, using the +tld_length+ + # to split the domain from the host. # * <tt>:tld_length</tt> - Number of labels the TLD id composed of, only used if # <tt>:subdomain</tt> or <tt>:domain</tt> are supplied. Defaults to # <tt>ActionDispatch::Http::URL.tld_length</tt>, which in turn defaults to 1. |