diff --git a/src/controllers/tags.js b/src/controllers/tags.js index 392ff9201e..52ef647625 100644 --- a/src/controllers/tags.js +++ b/src/controllers/tags.js @@ -25,7 +25,7 @@ tagsController.getTag = async function (req, res) { breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[tags:tags]]', url: '/tags' }, { text: tag }]), title: `[[pages:tag, ${tag}]]`, }; - const [settings, cids, categoryData, canPost, isPrivileged, rssToken, isFollowing] = await Promise.all([ + let [settings, cids, categoryData, canPost, isPrivileged, rssToken, isFollowing] = await Promise.all([ user.getSettings(req.uid), cid || categories.getCidsByPrivilege('categories:cid', req.uid, 'topics:read'), helpers.getSelectedCategory(cid), @@ -34,6 +34,14 @@ tagsController.getTag = async function (req, res) { user.auth.getFeedToken(req.uid), topics.isFollowingTag(req.params.tag, req.uid), ]); + + // Explicitly exclude cid -1 if cid not specified + if (!cid) { + cids = new Set(cids); + cids.delete(-1); + cids = Array.from(cids); + } + const start = Math.max(0, (page - 1) * settings.topicsPerPage); const stop = start + settings.topicsPerPage - 1;