mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Do not redirect to editor if parameter does not equal edit.
Closes #2619 - If edit parameter is 'edit' redirect to editor. - If edit parameter is anything other then undefined redirect to 404. - Create edit post tests. - Test redirect without trailing slash. - Test redirect to editor. - Test redirect to 404.
This commit is contained in:
parent
65b604c939
commit
87077f2218
2 changed files with 30 additions and 1 deletions
|
@ -183,8 +183,11 @@ frontendControllers = {
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
// If we're ready to render the page but the last param is 'edit' then we'll send you to the edit page.
|
// If we're ready to render the page but the last param is 'edit' then we'll send you to the edit page.
|
||||||
if (params.edit !== undefined) {
|
if (params.edit === 'edit') {
|
||||||
return res.redirect(config().paths.subdir + '/ghost/editor/' + post.id + '/');
|
return res.redirect(config().paths.subdir + '/ghost/editor/' + post.id + '/');
|
||||||
|
} else if (params.edit !== undefined) {
|
||||||
|
// Use throw 'no match' to show 404.
|
||||||
|
throw new Error('no match');
|
||||||
}
|
}
|
||||||
filters.doFilter('prePostsRender', post).then(function (post) {
|
filters.doFilter('prePostsRender', post).then(function (post) {
|
||||||
api.settings.read('activeTheme').then(function (activeTheme) {
|
api.settings.read('activeTheme').then(function (activeTheme) {
|
||||||
|
|
|
@ -117,6 +117,32 @@ describe('Frontend Routing', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Post edit', function () {
|
||||||
|
it('should redirect without slash', function (done) {
|
||||||
|
request.get('/welcome-to-ghost/edit')
|
||||||
|
.expect('Location', '/welcome-to-ghost/edit/')
|
||||||
|
.expect('Cache-Control', cacheRules.year)
|
||||||
|
.expect(301)
|
||||||
|
.end(doEnd(done));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should redirect to editor', function (done) {
|
||||||
|
request.get('/welcome-to-ghost/edit/')
|
||||||
|
.expect('Location', '/ghost/editor/1/')
|
||||||
|
.expect('Cache-Control', cacheRules['public'])
|
||||||
|
.expect(302)
|
||||||
|
.end(doEnd(done));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should 404 for non-edit parameter', function (done) {
|
||||||
|
request.get('/welcome-to-ghost/notedit/')
|
||||||
|
.expect('Cache-Control', cacheRules['private'])
|
||||||
|
.expect(404)
|
||||||
|
.expect(/Page Not Found/)
|
||||||
|
.end(doEnd(done));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('RSS', function () {
|
describe('RSS', function () {
|
||||||
it('should redirect without slash', function (done) {
|
it('should redirect without slash', function (done) {
|
||||||
request.get('/rss')
|
request.get('/rss')
|
||||||
|
|
Loading…
Add table
Reference in a new issue