Skip to content

Node.js based forum software built for the modern web

reworked logic in user.blocks.filter

Julian Lam9751c4b8dbbe
diff --git a/src/user/blocks.js b/src/user/blocks.js
index 5834fdd0b4..e0477a2cc4 100644
--- a/src/user/blocks.js
+++ b/src/user/blocks.js
@@ -76,7 +76,10 @@ module.exports = function (User) {
property = 'uid';
}
- if (!set || !Array.isArray(set) || !set.length || !(set[0].hasOwnProperty(property) || typeof set[0] === 'number' || typeof set[0] === 'string')) {
+ if (!Array.isArray(set) || !set.length || !set.every((item) => {
+ const check = item.hasOwnProperty(property) ? item[property] : item;
+ return item && ['number', 'string'].includes(typeof check);
+ })) {
return callback(null, set);
}