0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Fix /author/ pages crashing & permit /tag/

fixes #5905

- update context patterns to correctly match author & tag pages
- remove 'tag' and 'tags' from reserved slugs - we'll handle this in terms of overrides in future
This commit is contained in:
Hannah Wolfe 2015-10-10 14:45:54 +01:00
parent eed6879845
commit 26231d5bd3
3 changed files with 19 additions and 3 deletions

View file

@ -212,7 +212,7 @@ ConfigManager.prototype.set = function (config) {
// Used by generateSlug to generate slugs for posts, tags, users, ..
// reserved slugs are reserved but can be extended/removed by apps
// protected slugs cannot be changed or removed
reserved: ['admin', 'app', 'apps', 'archive', 'archives', 'categories', 'category', 'dashboard', 'feed', 'ghost-admin', 'login', 'logout', 'page', 'pages', 'post', 'posts', 'public', 'register', 'setup', 'signin', 'signout', 'signup', 'tag', 'tags', 'user', 'users', 'wp-admin', 'wp-login'],
reserved: ['admin', 'app', 'apps', 'archive', 'archives', 'categories', 'category', 'dashboard', 'feed', 'ghost-admin', 'login', 'logout', 'page', 'pages', 'post', 'posts', 'public', 'register', 'setup', 'signin', 'signout', 'signup', 'user', 'users', 'wp-admin', 'wp-login'],
protected: ['ghost', 'rss']
},
uploads: {

View file

@ -72,8 +72,8 @@ function handleError(next) {
function setResponseContext(req, res, data) {
var contexts = [],
pageParam = req.params.page !== undefined ? parseInt(req.params.page, 10) : 1,
tagPattern = new RegExp('^\\/' + config.routeKeywords.tag + '\\/'),
authorPattern = new RegExp('^\\/' + config.routeKeywords.author + '\\/'),
tagPattern = new RegExp('^\\/' + config.routeKeywords.tag + '\\/.+'),
authorPattern = new RegExp('^\\/' + config.routeKeywords.author + '\\/.+'),
privatePattern = new RegExp('^\\/' + config.routeKeywords.private + '\\/'),
indexPattern = new RegExp('^\\/' + config.routeKeywords.page + '\\/'),
homePattern = new RegExp('^\\/$');

View file

@ -526,6 +526,14 @@ describe('Frontend Routing', function () {
after(testUtils.teardown);
it('should 404 for /author/ route', function (done) {
request.get('/author/')
.expect('Cache-Control', testUtils.cacheRules['private'])
.expect(404)
.expect(/Page not found/)
.end(doEnd(done));
});
it('should redirect without slash', function (done) {
request.get('/author/ghost-owner/page/2')
.expect('Location', '/author/ghost-owner/page/2/')
@ -653,6 +661,14 @@ describe('Frontend Routing', function () {
after(testUtils.teardown);
it('should 404 for /tag/ route', function (done) {
request.get('/tag/')
.expect('Cache-Control', testUtils.cacheRules['private'])
.expect(404)
.expect(/Page not found/)
.end(doEnd(done));
});
it('should redirect without slash', function (done) {
request.get('/tag/injection/page/2')
.expect('Location', '/tag/injection/page/2/')