提交 34f61f8b 编写于 作者: J José Valim

Merge pull request #3568 from bfolkens/master-url_subdomain_with_numeric_host

Fix trouble using :subdomain in development environment when using numeric addresses.
......@@ -64,7 +64,7 @@ def rewrite_authentication(options)
end
def host_or_subdomain_and_domain(options)
return options[:host] if options[:subdomain].nil? && options[:domain].nil?
return options[:host] if !named_host?(options[:host]) || (options[:subdomain].nil? && options[:domain].nil?)
tld_length = options[:tld_length] || @@tld_length
......
......@@ -16,6 +16,10 @@ def add_host!
W.default_url_options[:host] = 'www.basecamphq.com'
end
def add_numeric_host!
W.default_url_options[:host] = '127.0.0.1'
end
def test_exception_is_thrown_without_host
assert_raise ArgumentError do
W.new.url_for :controller => 'c', :action => 'a', :id => 'i'
......@@ -81,6 +85,13 @@ def test_multiple_subdomains_may_be_removed
)
end
def test_subdomain_may_be_accepted_with_numeric_host
add_numeric_host!
assert_equal('http://127.0.0.1/c/a/i',
W.new.url_for(:subdomain => 'api', :controller => 'c', :action => 'a', :id => 'i')
)
end
def test_domain_may_be_changed
add_host!
assert_equal('http://www.37signals.com/c/a/i',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册