🐛 Fixed redirect issue with private sites (#9960)

closes #9959

This issue existed because the logic assumed that if there were no
query parameters then there would be no `query` object. However this is
not the case. What we really wanted to check was for the existence of an
"r" query param - the code has been refactor to explicitly do this now.
This commit is contained in:
Fabien O'Carroll 2018-10-08 16:31:08 +07:00
parent 68c56d9539
commit eb22429338
2 changed files with 4 additions and 2 deletions

View File

@ -22,7 +22,7 @@ function verifySessionHash(salt, hash) {
}
function getRedirectUrl(query) {
const redirect = decodeURIComponent(query ? query.r : '/');
const redirect = decodeURIComponent(query.r || '/');
try {
return new url.URL(redirect, urlService.utils.urlFor('home', true)).pathname;
} catch (e) {

View File

@ -25,7 +25,9 @@ describe('Private Blogging', function () {
var req, res, next;
beforeEach(function () {
req = {};
req = {
query: {}
};
res = {};
settingsStub = sandbox.stub(settingsCache, 'get');
next = sandbox.spy();