mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
use or clause for display name and username search (#12820)
* use or clause for display name and username search * update styling * More style fix * update comment and regex
This commit is contained in:
@@ -322,9 +322,12 @@ function _getMembersForItem (type) {
|
||||
}
|
||||
|
||||
if (req.query.search) {
|
||||
// Creates a RegExp expression when querying for profile.name
|
||||
// Creates a RegExp expression when querying for profile.name and auth.local.username
|
||||
const escapedSearch = escapeRegExp(req.query.search);
|
||||
query['profile.name'] = { $regex: new RegExp(escapedSearch, 'i') };
|
||||
query.$or = [
|
||||
{ 'profile.name': { $regex: new RegExp(escapedSearch, 'i') } },
|
||||
{ 'auth.local.username': { $regex: new RegExp(req.query.search, 'i') } },
|
||||
];
|
||||
}
|
||||
} else if (type === 'group-invites') {
|
||||
if (group.type === 'guild') { // eslint-disable-line no-lonely-if
|
||||
|
||||
Reference in New Issue
Block a user