diff --git a/public_html/js/Presenters/PagerPresenter.js b/public_html/js/Presenters/PagerPresenter.js
index 8475fe77..12317a04 100644
--- a/public_html/js/Presenters/PagerPresenter.js
+++ b/public_html/js/Presenters/PagerPresenter.js
@@ -82,11 +82,12 @@ App.Presenters.PagerPresenter = function(
function getUrl(options) {
return util.appendComplexRouteParam(
baseUri,
- _.extend(
- {},
- pager.getSearchParams(),
- {page: pager.getPage()},
- options));
+ util.simplifySearchQuery(
+ _.extend(
+ {},
+ pager.getSearchParams(),
+ {page: pager.getPage()},
+ options)));
}
function syncUrl(options) {
diff --git a/public_html/js/Services/PostsAroundCalculator.js b/public_html/js/Services/PostsAroundCalculator.js
index 19aa9fd4..de53ffd9 100644
--- a/public_html/js/Services/PostsAroundCalculator.js
+++ b/public_html/js/Services/PostsAroundCalculator.js
@@ -41,7 +41,11 @@ App.Services.PostsAroundCalculator = function(_, promise, util, pager) {
if (position + direction >= 0 && position + direction < postIds.length) {
var url = util.appendComplexRouteParam(
'#/post/' + postIds[position + direction],
- _.extend({page: page}, pager.getSearchParams()));
+ util.simplifySearchQuery(
+ _.extend(
+ {page: page},
+ pager.getSearchParams())));
+
resolve(url);
} else if (page + direction >= 1) {
pager.setPage(page + direction);
@@ -54,7 +58,11 @@ App.Services.PostsAroundCalculator = function(_, promise, util, pager) {
var url = util.appendComplexRouteParam(
'#/post/' + post.id,
- _.extend({page: page + direction}, pager.getSearchParams()));
+ util.simplifySearchQuery(
+ _.extend(
+ {page: page + direction},
+ pager.getSearchParams())));
+
resolve(url);
} else {
resolve(null);
diff --git a/public_html/js/Util/Misc.js b/public_html/js/Util/Misc.js
index 7ff017e9..014423bb 100644
--- a/public_html/js/Util/Misc.js
+++ b/public_html/js/Util/Misc.js
@@ -237,6 +237,17 @@ App.Util.Misc = function(_, jQuery, marked, promise) {
return result.slice(0, -1);
}
+ function simplifySearchQuery(query) {
+ if (typeof(query) === 'undefined') {
+ return {};
+ }
+ if (query.page === 1) {
+ delete query.page;
+ }
+ query = _.pick(query, _.identity); //remove falsy values
+ return query;
+ }
+
return {
promiseTemplate: promiseTemplate,
formatRelativeTime: formatRelativeTime,
@@ -249,6 +260,7 @@ App.Util.Misc = function(_, jQuery, marked, promise) {
transparentPixel: transparentPixel,
loadImagesNicely: loadImagesNicely,
appendComplexRouteParam: appendComplexRouteParam,
+ simplifySearchQuery: simplifySearchQuery,
};
};
diff --git a/public_html/templates/post-list-item.tpl b/public_html/templates/post-list-item.tpl
index d91401ac..525156fc 100644
--- a/public_html/templates/post-list-item.tpl
+++ b/public_html/templates/post-list-item.tpl
@@ -2,7 +2,7 @@
<% if (canViewPosts) { %>
<% } else { %>
diff --git a/public_html/templates/post.tpl b/public_html/templates/post.tpl
index b87274f6..65d17303 100644
--- a/public_html/templates/post.tpl
+++ b/public_html/templates/post.tpl
@@ -10,7 +10,7 @@