Skip to content

Commit

Permalink
🐛 Fixed /edit shortcut not working in Safari (#9637)
Browse files Browse the repository at this point in the history
closes #9633 
- use non-hash URL for admin redirects so that redirects are followed correctly by Safari when admin is on different domain
  • Loading branch information
ololoken authored and kevinansfield committed May 21, 2018
1 parent 2cc0325 commit 86c28e3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/server/controllers/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function entryController(req, res, next) {

// CASE: last param is of url is /edit, redirect to admin
if (lookup.isEditURL) {
return urlService.utils.redirectToAdmin(302, res, '#/editor/' + post.id);
return urlService.utils.redirectToAdmin(302, res, '/editor/' + post.id);
}

// CASE: permalink is not valid anymore, we redirect him permanently to the correct one
Expand Down
2 changes: 1 addition & 1 deletion core/server/controllers/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function previewController(req, res, next) {

if (req.params.options && req.params.options.toLowerCase() === 'edit') {
// CASE: last param is of url is /edit, redirect to admin
return urlService.utils.redirectToAdmin(302, res, '#/editor/' + post.id);
return urlService.utils.redirectToAdmin(302, res, '/editor/' + post.id);
} else if (req.params.options) {
// CASE: unknown options param detected. Ignore and end in 404.
return next();
Expand Down
4 changes: 2 additions & 2 deletions core/test/functional/routes/frontend_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('Frontend Routing', function () {

it('should redirect to editor', function (done) {
request.get('/welcome/edit/')
.expect('Location', /ghost\/#\/editor\/\w+/)
.expect('Location', /ghost\/editor\/\w+/)
.expect('Cache-Control', testUtils.cacheRules.public)
.expect(302)
.end(doEnd(done));
Expand Down Expand Up @@ -399,7 +399,7 @@ describe('Frontend Routing', function () {

it('should redirect to editor', function (done) {
request.get('/static-page-test/edit/')
.expect('Location', /ghost\/#\/editor\/\w+/)
.expect('Location', /ghost\/editor\/\w+/)
.expect('Cache-Control', testUtils.cacheRules.public)
.expect(302)
.end(doEnd(done));
Expand Down
2 changes: 1 addition & 1 deletion core/test/unit/controllers/entry_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var should = require('should'),
sandbox = sinon.sandbox.create();

describe('Controllers', function () {
var adminEditPagePath = '/ghost/#/editor/',
var adminEditPagePath = '/ghost/editor/',
localSettingsCache = {},
hasTemplateStub;

Expand Down
2 changes: 1 addition & 1 deletion core/test/unit/controllers/preview_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('Controllers', function () {
res.redirect = function (url) {
res.render.called.should.be.false();
res.set.called.should.be.false();
url.should.eql('/ghost/#/editor/1/');
url.should.eql('/ghost/editor/1/');

done();
};
Expand Down

0 comments on commit 86c28e3

Please sign in to comment.