Skip to content

Commit

Permalink
🐛 Fixed redirect issue with private sites (#9960)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
allouis committed Nov 7, 2018
1 parent 68c56d9 commit eb22429
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/server/apps/private-blogging/lib/middleware.js
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion core/test/unit/apps/private-blogging/middleware_spec.js
Expand Up @@ -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();
Expand Down

0 comments on commit eb22429

Please sign in to comment.