diff --git a/client/js/controllers/users_controller.js b/client/js/controllers/users_controller.js index 12e8899..07d6f17 100644 --- a/client/js/controllers/users_controller.js +++ b/client/js/controllers/users_controller.js @@ -59,8 +59,8 @@ class UsersController { text: ctx.searchQuery.text, page: page})); }, - clientUrl: '/users/text={text};page={page}'.format({ - text: ctx.searchQuery.text}), + clientUrl: '/users/' + misc.formatSearchQuery({ + text: ctx.searchQuery.text, page: '{page}'}), initialPage: ctx.searchQuery.page, pageRenderer: this.userListView, }); diff --git a/client/js/util/misc.js b/client/js/util/misc.js index 9e8f13a..38f54ff 100644 --- a/client/js/util/misc.js +++ b/client/js/util/misc.js @@ -52,6 +52,17 @@ function formatRelativeTime(timeString) { return future ? 'in ' + text : text + ' ago'; } +function formatSearchQuery(dict) { + let result = []; + for (let key of Object.keys(dict)) { + const value = dict[key]; + if (value) { + result.push('{0}={1}'.format(key, value)); + } + } + return result.join(''); +} + function parseSearchQuery(query) { let result = {}; for (let word of (query || '').split(/;/)) { @@ -70,6 +81,7 @@ function parseSearchQueryRoute(ctx, next) { module.exports = { range: range, + formatSearchQuery: formatSearchQuery, parseSearchQuery: parseSearchQuery, parseSearchQueryRoute: parseSearchQueryRoute, formatRelativeTime: formatRelativeTime,