1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Keep the query string and path in store_location_for

Persist the URI's query when saving to the session.

Fixes #2742
This commit is contained in:
Christopher Sexton 2013-11-20 15:47:20 -05:00
parent bb2ff3553b
commit 7afc096fa4
2 changed files with 10 additions and 2 deletions

View file

@ -33,7 +33,10 @@ module Devise
#
def store_location_for(resource_or_scope, location)
session_key = stored_location_key_for(resource_or_scope)
session[session_key] = URI.parse(location).path.sub(/\A\/+/, '/') if location
if location
uri = URI.parse(location)
session[session_key] = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
end
end
private

View file

@ -198,13 +198,18 @@ class ControllerAuthenticatableTest < ActionController::TestCase
assert_equal "/foo.bar", @controller.stored_location_for(User.new)
end
test 'store location for stores only paths' do
test 'store location for stores paths' do
@controller.store_location_for(:user, "//host/foo.bar")
assert_equal "/foo.bar", @controller.stored_location_for(:user)
@controller.store_location_for(:user, "///foo.bar")
assert_equal "/foo.bar", @controller.stored_location_for(:user)
end
test 'store location for stores query string' do
@controller.store_location_for(:user, "/foo?bar=baz")
assert_equal "/foo?bar=baz", @controller.stored_location_for(:user)
end
test 'after sign in path defaults to root path if none by was specified for the given scope' do
assert_equal root_path, @controller.after_sign_in_path_for(:user)
end