From 85e42aee6e2ef8e5f3b0aa400ac951978c513fc3 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Sun, 17 Jul 2016 15:47:58 -0500 Subject: [PATCH] make ?page=[numbers] links work for users with pagination disabled. remove ?page when updating the URL for infinite scroll --- public/src/client/topic.js | 2 +- src/controllers/topics.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/src/client/topic.js b/public/src/client/topic.js index ce320309f2..da4e5456e8 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -260,7 +260,7 @@ define('forum/topic', [ Topic.replaceURLTimeout = 0; if (history.replaceState) { - var search = (window.location.search ? window.location.search : ''); + var search = (window.location.search && !/^\?page=\d+$/.test(window.location.search) ? window.location.search : ''); history.replaceState({ url: newUrl + search }, null, window.location.protocol + '//' + window.location.host + RELATIVE_PATH + '/' + newUrl + search); diff --git a/src/controllers/topics.js b/src/controllers/topics.js index 1e41cfe981..c65996b82c 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -97,7 +97,9 @@ topicsController.get = function(req, res, callback) { req.params.post_index = 0; } if (!settings.usePagination) { - currentPage = 1; + if (req.params.post_index !== 0) { + currentPage = 1; + } if (reverse) { postIndex = Math.max(0, postCount - (req.params.post_index || postCount) - Math.ceil(settings.postsPerPage / 2)); } else {