mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
Merge pull request #467 from jgable/titleFixes
Trim title and don't allow negative pages
This commit is contained in:
commit
fef1aae7be
@ -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) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user