Skip to content

Node.js based forum software built for the modern web

group search change

barisusakli63489457fe0c
diff --git a/src/groups.js b/src/groups.js
index 72cb0e9b28..02e24a41bb 100644
--- a/src/groups.js
+++ b/src/groups.js
@@ -1098,19 +1098,17 @@ var async = require('async'),
Groups.search = function(query, options, callback) {
if (!query) {
- query = '';
+ return callback(null, []);
}
-
+ query = query.toLowerCase();
async.waterfall([
async.apply(db.getObjectValues, 'groupslug:groupname'),
function(groupNames, next) {
groupNames = groupNames.filter(function(name) {
- return name.match(new RegExp(query, 'i')) && name !== 'administrators';
+ return name.toLowerCase().indexOf(query) !== -1 && name !== 'administrators';
});
-
- async.mapLimit(groupNames, 5, function(groupName, next) {
- Groups.get(groupName, options || {}, next);
- }, next);
+ groupNames = groupNames.slice(0, 100);
+ Groups.getGroupsData(groupNames, next);
},
async.apply(Groups.sort, options.sort)
], callback);