1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fixed force_ssl redirects to include original query params

`ActionController.force_ssl` redirects http URLs to their https equivalent;
however, when a URL contains a query string, the resulting redirect lacked the
original query string.

Conflicts:

	actionpack/lib/action_controller/metal/force_ssl.rb
This commit is contained in:
Ryan McGeary 2012-02-06 17:47:17 -05:00
parent 275c3a1cb3
commit 6efb849b32
3 changed files with 8 additions and 0 deletions

View file

@ -29,6 +29,7 @@ module ActionController
if !request.ssl? && !Rails.env.development?
redirect_options = {:protocol => 'https://', :status => :moved_permanently}
redirect_options.merge!(:host => host) if host
redirect_options.merge!(:params => request.query_parameters)
flash.keep
redirect_to redirect_options
end

View file

@ -567,6 +567,7 @@ module ActionDispatch
path_addition, params = generate(path_options, path_segments || {})
path << path_addition
params.merge!(options[:params] || {})
ActionDispatch::Http::URL.url_for(options.merge!({
:path => path,

View file

@ -50,6 +50,12 @@ class ForceSSLControllerLevelTest < ActionController::TestCase
assert_equal "https://test.host/force_ssl_controller_level/banana", redirect_to_url
end
def test_banana_redirects_to_https_with_extra_params
get :banana, :token => "secret"
assert_response 301
assert_equal "https://test.host/force_ssl_controller_level/banana?token=secret", redirect_to_url
end
def test_cheeseburger_redirects_to_https
get :cheeseburger
assert_response 301