mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Add rss
to the list of reserved post titles/slugs.
closes #1880 - added `rss` to core/server/models `generateSlug` reserved keywords - added integration test for safe slug generation to core/test/integration/model/model_posts_spec.js
This commit is contained in:
parent
8f02b3341b
commit
e8746a2375
2 changed files with 13 additions and 1 deletions
|
@ -227,7 +227,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
|
|||
// Remove non ascii characters
|
||||
slug = unidecode(slug);
|
||||
// Check the filtered slug doesn't match any of the reserved keywords
|
||||
slug = /^(ghost|ghost\-admin|admin|wp\-admin|wp\-login|dashboard|logout|login|signin|signup|signout|register|archive|archives|category|categories|tag|tags|page|pages|post|posts|user|users)$/g
|
||||
slug = /^(ghost|ghost\-admin|admin|wp\-admin|wp\-login|dashboard|logout|login|signin|signup|signout|register|archive|archives|category|categories|tag|tags|page|pages|post|posts|user|users|rss)$/g
|
||||
.test(slug) ? slug + '-post' : slug;
|
||||
|
||||
//if slug is empty after trimming use "post"
|
||||
|
|
|
@ -255,6 +255,18 @@ describe('Post Model', function () {
|
|||
}).then(null, done);
|
||||
});
|
||||
|
||||
it('can generate a safe slug when a reserved keyword is used', function(done) {
|
||||
var newPost = {
|
||||
title: 'rss',
|
||||
markdown: 'Test Content 1'
|
||||
};
|
||||
|
||||
PostModel.add(newPost).then(function (createdPost) {
|
||||
createdPost.get('slug').should.not.equal('rss');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can generate slugs without non-ascii characters', function (done) {
|
||||
var newPost = {
|
||||
title: 'भुते धडकी भरवणारा आहेत',
|
||||
|
|
Loading…
Add table
Reference in a new issue