mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: properly handle empty fields param
This commit is contained in:
@@ -38,11 +38,14 @@ module.exports = function (Categories) {
|
|||||||
|
|
||||||
// Handle cid -1
|
// Handle cid -1
|
||||||
if (cids.includes(-1)) {
|
if (cids.includes(-1)) {
|
||||||
const subset = fields.reduce((category, field) => {
|
let subset = null;
|
||||||
category[field] = worldCategory[field] || undefined;
|
if (fields && fields.length) {
|
||||||
return category;
|
subset = fields.reduce((category, field) => {
|
||||||
}, {});
|
category[field] = worldCategory[field] || undefined;
|
||||||
categories.splice(cids.indexOf(-1), 1, subset);
|
return category;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
categories.splice(cids.indexOf(-1), 1, subset || worldCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await plugins.hooks.fire('filter:category.getFields', {
|
const result = await plugins.hooks.fire('filter:category.getFields', {
|
||||||
|
|||||||
Reference in New Issue
Block a user