Merge pull request #467 from jgable/titleFixes

Trim title and don't allow negative pages
This commit is contained in:
Hannah Wolfe 2013-08-20 01:12:33 -07:00
commit fef1aae7be
2 changed files with 7 additions and 1 deletions

View File

@ -14,6 +14,12 @@ frontendControllers = {
'homepage': function (req, res) {
// Parse the page number
var pageParam = req.params.page !== undefined ? parseInt(req.params.page, 10) : 1;
// No negative pages
if (pageParam < 1) {
return res.redirect("/page/1/");
}
api.posts.browse({page: pageParam}).then(function (page) {
// If page is greater than number of pages we have, redirect to last page
if (pageParam > page.pages) {

View File

@ -95,7 +95,7 @@ Post = GhostBookshelf.Model.extend({
};
// Remove URL reserved chars: `:/?#[]@!$&'()*+,;=` as well as `\%<>|^~£"`
slug = title.replace(/[:\/\?#\[\]@!$&'()*+,;=\\%<>\|\^~£"]/g, '')
slug = title.trim().replace(/[:\/\?#\[\]@!$&'()*+,;=\\%<>\|\^~£"]/g, '')
// Replace dots and spaces with a dash
.replace(/(\s|\.)/g, '-')
// Convert 2 or more dashes into a single dash