0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Merge pull request #486 from jgable/fixRedirectLoop

Fix redirect loop when no content
This commit is contained in:
Hannah Wolfe 2013-08-22 02:19:06 -07:00
commit 6c6119a5c8

View file

@ -21,9 +21,17 @@ frontendControllers = {
}
api.posts.browse({page: pageParam}).then(function (page) {
var maxPage = page.pages;
// A bit of a hack for situations with no content.
if (maxPage === 0) {
maxPage = 1;
page.pages = 1;
}
// If page is greater than number of pages we have, redirect to last page
if (pageParam > page.pages) {
return res.redirect("/page/" + (page.pages) + "/");
if (pageParam > maxPage) {
return res.redirect("/page/" + maxPage + "/");
}
// Render the page of posts