-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #8140 β¨ Support new default-prod.hbs template for admin β¨ Redirect ghost admin urls without a # β¨ Update admin urls to include # π¨ Move the admin templates π₯ Remove redirect to setup middleware π¨ Tests for new middleware
- Loading branch information
Showing
15 changed files
with
102 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var utils = require('../utils'); | ||
|
||
function redirectAdminUrls(req, res, next) { | ||
var ghostPathMatch = req.originalUrl.match(/^\/ghost\/(.+)$/); | ||
if (ghostPathMatch) { | ||
return res.redirect(utils.url.urlJoin(utils.url.urlFor('admin'), '#', ghostPathMatch[1])); | ||
} | ||
|
||
next(); | ||
} | ||
|
||
module.exports = [ | ||
redirectAdminUrls | ||
]; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
var should = require('should'), // jshint ignore:line | ||
sinon = require('sinon'), | ||
|
||
// Thing we are testing | ||
redirectAdminUrls = require('../../server/admin/middleware')[0], | ||
|
||
sandbox = sinon.sandbox.create(); | ||
describe('Admin App', function () { | ||
afterEach(function () { | ||
sandbox.restore(); | ||
}); | ||
|
||
describe('middleware', function () { | ||
describe('redirectAdminUrls', function () { | ||
var req, res, next; | ||
// Input: req.originalUrl | ||
// Output: either next or res.redirect are called | ||
beforeEach(function () { | ||
req = {}; | ||
res = {}; | ||
next = sandbox.stub(); | ||
res.redirect = sandbox.stub(); | ||
}); | ||
|
||
it('should redirect a url which starts with ghost', function () { | ||
req.originalUrl = '/ghost/x'; | ||
|
||
redirectAdminUrls(req, res, next); | ||
|
||
next.called.should.be.false(); | ||
res.redirect.called.should.be.true(); | ||
res.redirect.calledWith('/ghost/#/x').should.be.true(); | ||
}); | ||
|
||
it('should not redirect /ghost/ on its owh', function () { | ||
req.originalUrl = '/ghost/'; | ||
|
||
redirectAdminUrls(req, res, next); | ||
|
||
next.called.should.be.true(); | ||
res.redirect.called.should.be.false(); | ||
}); | ||
|
||
it('should not redirect url that has no slash', function () { | ||
req.originalUrl = 'ghost/x'; | ||
|
||
redirectAdminUrls(req, res, next); | ||
|
||
next.called.should.be.true(); | ||
res.redirect.called.should.be.false(); | ||
}); | ||
|
||
it('should not redirect url that starts with something other than /ghost/', function () { | ||
req.originalUrl = 'x/ghost/x'; | ||
|
||
redirectAdminUrls(req, res, next); | ||
|
||
next.called.should.be.true(); | ||
res.redirect.called.should.be.false(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.