0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

fixes #202 - urls contain reserved chars

- added all reserved chars and \ to the list of chars which get filtered out
- added documentation
This commit is contained in:
Hannah Wolfe 2013-06-25 19:07:19 +01:00
parent 1005be472a
commit 7993cc22ab

View file

@ -58,8 +58,11 @@ Post = GhostBookshelf.Model.extend({
}
},
// #### generateSlug
// Create a string act as the permalink for a post.
// Remove reserved chars: `:/?#[]@!$&'()*+,;=` as well as `\` and convert spaces to hyphens
generateSlug: function () {
return this.set('slug', this.get('title').replace(/\:/g, '').replace(/\s/g, '-').toLowerCase());
return this.set('slug', this.get('title').replace(/[:\/\?#\[\]@!$&'()*+,;=\\]/g, '').replace(/\s/g, '-').toLowerCase());
},
user: function () {
@ -72,21 +75,24 @@ Post = GhostBookshelf.Model.extend({
}, {
/**
* Find results by page - returns an object containing the
* information about the request (page, limit), along with the
* info needed for pagination (pages, total).
*
* {
* posts: [
* {...}, {...}, {...}
* ],
* page: __,
* limit: __,
* pages: __,
* total: __
* }
*
// #### findPage
// Find results by page - returns an object containing the
// information about the request (page, limit), along with the
// info needed for pagination (pages, total).
// **response:**
// {
// posts: [
// {...}, {...}, {...}
// ],
// page: __,
// limit: __,
// pages: __,
// total: __
// }
/*
* @params opts
*/
findPage: function (opts) {