From f36efc0cc98579cc54bb7f0336078f5fbb6ab1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 13 Nov 2013 15:01:23 +0100 Subject: [PATCH] Ensure multiple leading / are also removed, thanks @homakov --- lib/devise/controllers/store_location.rb | 2 +- test/controllers/helpers_test.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/devise/controllers/store_location.rb b/lib/devise/controllers/store_location.rb index c1592831..a701d34f 100644 --- a/lib/devise/controllers/store_location.rb +++ b/lib/devise/controllers/store_location.rb @@ -33,7 +33,7 @@ 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 if location + session[session_key] = URI.parse(location).path.sub(/\A\/+/, '/') if location end private diff --git a/test/controllers/helpers_test.rb b/test/controllers/helpers_test.rb index fee034be..0238ba1a 100644 --- a/test/controllers/helpers_test.rb +++ b/test/controllers/helpers_test.rb @@ -199,9 +199,10 @@ class ControllerAuthenticatableTest < ActionController::TestCase end test 'store location for stores only paths' do - assert_nil @controller.stored_location_for(:user) @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 'after sign in path defaults to root path if none by was specified for the given scope' do