From c76d4018f26f1a6d78e5c680cef5bbc7e4538714 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 15 Mar 2024 12:07:33 -0400 Subject: [PATCH] fix: properly handle empty fields param --- src/categories/data.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/categories/data.js b/src/categories/data.js index 92ed1e64f5..4ce80b496f 100644 --- a/src/categories/data.js +++ b/src/categories/data.js @@ -38,11 +38,14 @@ module.exports = function (Categories) { // Handle cid -1 if (cids.includes(-1)) { - const subset = fields.reduce((category, field) => { - category[field] = worldCategory[field] || undefined; - return category; - }, {}); - categories.splice(cids.indexOf(-1), 1, subset); + let subset = null; + if (fields && fields.length) { + subset = fields.reduce((category, field) => { + category[field] = worldCategory[field] || undefined; + return category; + }, {}); + } + categories.splice(cids.indexOf(-1), 1, subset || worldCategory); } const result = await plugins.hooks.fire('filter:category.getFields', {