mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
remove the :path feature to redirects, since it cannot work
This commit is contained in:
@@ -68,23 +68,15 @@ module ActionDispatch
|
||||
|
||||
def options_proc(options)
|
||||
proc do |params, request|
|
||||
path = if options[:path].nil?
|
||||
request.path
|
||||
elsif params.empty? || !options[:path].match(/%\{\w*\}/)
|
||||
options.delete(:path)
|
||||
else
|
||||
(options.delete(:path) % params)
|
||||
end
|
||||
|
||||
default_options = {
|
||||
url_options = {
|
||||
:protocol => request.protocol,
|
||||
:host => request.host,
|
||||
:port => request.optional_port,
|
||||
:path => path,
|
||||
:params => request.query_parameters
|
||||
}
|
||||
:host => request.host,
|
||||
:port => request.optional_port,
|
||||
:path => request.path,
|
||||
:params => request.query_parameters
|
||||
}.merge options
|
||||
|
||||
ActionDispatch::Http::URL.url_for(options.reverse_merge(default_options))
|
||||
ActionDispatch::Http::URL.url_for url_options
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -62,13 +62,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
||||
match 'secure', :to => redirect("/secure/login")
|
||||
|
||||
match 'mobile', :to => redirect(:subdomain => 'mobile')
|
||||
match 'documentation', :to => redirect(:domain => 'example-documentation.com', :path => '')
|
||||
match 'new_documentation', :to => redirect(:path => '/documentation/new')
|
||||
match 'super_new_documentation', :to => redirect(:host => 'super-docs.com')
|
||||
|
||||
match 'stores/:name', :to => redirect(:subdomain => 'stores', :path => '/%{name}')
|
||||
match 'stores/:name(*rest)', :to => redirect(:subdomain => 'stores', :path => '/%{name}%{rest}')
|
||||
|
||||
match 'youtube_favorites/:youtube_id/:name', :to => redirect(YoutubeFavoritesRedirector)
|
||||
|
||||
constraints(lambda { |req| true }) do
|
||||
@@ -711,20 +706,6 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
def test_redirect_hash_with_domain_and_path
|
||||
with_test_routes do
|
||||
get '/documentation'
|
||||
verify_redirect 'http://www.example-documentation.com'
|
||||
end
|
||||
end
|
||||
|
||||
def test_redirect_hash_with_path
|
||||
with_test_routes do
|
||||
get '/new_documentation'
|
||||
verify_redirect 'http://www.example.com/documentation/new'
|
||||
end
|
||||
end
|
||||
|
||||
def test_redirect_hash_with_host
|
||||
with_test_routes do
|
||||
get '/super_new_documentation?section=top'
|
||||
@@ -732,20 +713,6 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
def test_redirect_hash_path_substitution
|
||||
with_test_routes do
|
||||
get '/stores/iernest'
|
||||
verify_redirect 'http://stores.example.com/iernest'
|
||||
end
|
||||
end
|
||||
|
||||
def test_redirect_hash_path_substitution_with_catch_all
|
||||
with_test_routes do
|
||||
get '/stores/iernest/products'
|
||||
verify_redirect 'http://stores.example.com/iernest/products'
|
||||
end
|
||||
end
|
||||
|
||||
def test_redirect_class
|
||||
with_test_routes do
|
||||
get '/youtube_favorites/oHg5SJYRHA0/rick-rolld'
|
||||
|
||||
Reference in New Issue
Block a user