0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -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 () { 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 () { user: function () {
@ -72,21 +75,24 @@ Post = GhostBookshelf.Model.extend({
}, { }, {
/** // #### findPage
* Find results by page - returns an object containing the // Find results by page - returns an object containing the
* information about the request (page, limit), along with the // information about the request (page, limit), along with the
* info needed for pagination (pages, total). // info needed for pagination (pages, total).
*
* { // **response:**
* posts: [
* {...}, {...}, {...} // {
* ], // posts: [
* page: __, // {...}, {...}, {...}
* limit: __, // ],
* pages: __, // page: __,
* total: __ // limit: __,
* } // pages: __,
* // total: __
// }
/*
* @params opts * @params opts
*/ */
findPage: function (opts) { findPage: function (opts) {