mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-05 15:20:39 +01:00
fix: circular object ref.
getCategoriesFields was returning full pseudo-category object even if fields were specific, now it only returns fields requested. navigating to /category/-1 now redirects to /world
This commit is contained in:
@@ -38,7 +38,11 @@ module.exports = function (Categories) {
|
||||
|
||||
// Handle cid -1
|
||||
if (cids.includes(-1)) {
|
||||
categories.splice(cids.indexOf(-1), 1, worldCategory);
|
||||
const subset = fields.reduce((category, field) => {
|
||||
category[field] = worldCategory[field] || undefined;
|
||||
return category;
|
||||
}, {});
|
||||
categories.splice(cids.indexOf(-1), 1, subset);
|
||||
}
|
||||
|
||||
const result = await plugins.hooks.fire('filter:category.getFields', {
|
||||
|
||||
@@ -26,6 +26,9 @@ const validSorts = [
|
||||
|
||||
categoryController.get = async function (req, res, next) {
|
||||
const cid = req.params.category_id;
|
||||
if (cid === '-1') {
|
||||
return helpers.redirect(res, `/world?${qs.stringify(req.query)}`);
|
||||
}
|
||||
|
||||
let currentPage = parseInt(req.query.page, 10) || 1;
|
||||
let topicIndex = utils.isNumber(req.params.topic_index) ? parseInt(req.params.topic_index, 10) - 1 : 0;
|
||||
|
||||
Reference in New Issue
Block a user