FEATURE: support query params when redirecting to internal link on login (#7829)
This commit is contained in:
parent
32edaa3843
commit
1708be4f27
|
@ -101,8 +101,7 @@ class StaticController < ApplicationController
|
||||||
(uri.host.blank? || uri.host == forum_uri.host) &&
|
(uri.host.blank? || uri.host == forum_uri.host) &&
|
||||||
uri.path !~ /\./
|
uri.path !~ /\./
|
||||||
|
|
||||||
destination = uri.path
|
destination = "#{uri.path}#{uri.query ? "?#{uri.query}" : ""}"
|
||||||
destination = "#{uri.path}?#{uri.query}" if uri.path =~ /new-topic/ || uri.path =~ /new-message/ || uri.path =~ /user-api-key/
|
|
||||||
end
|
end
|
||||||
rescue URI::Error
|
rescue URI::Error
|
||||||
# Do nothing if the URI is invalid
|
# Do nothing if the URI is invalid
|
||||||
|
|
|
@ -262,6 +262,13 @@ describe StaticController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with a redirect path with query params' do
|
||||||
|
it 'redirects to the redirect path and preserves query params' do
|
||||||
|
post "/login.json", params: { redirect: '/foo?bar=1' }
|
||||||
|
expect(response).to redirect_to('/foo?bar=1')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with a period to force a new host' do
|
context 'with a period to force a new host' do
|
||||||
it 'redirects to the root path' do
|
it 'redirects to the root path' do
|
||||||
post "/login.json", params: { redirect: ".org/foo" }
|
post "/login.json", params: { redirect: ".org/foo" }
|
||||||
|
|
Loading…
Reference in New Issue