mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
escape regex for searching users
This commit is contained in:
@@ -33,7 +33,7 @@ api.getHero = {
|
||||
|
||||
const { userIdentifier } = req.params;
|
||||
|
||||
const re = new RegExp(String.raw`${userIdentifier}`);
|
||||
const re = new RegExp(String.raw`${userIdentifier.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`);
|
||||
|
||||
let query;
|
||||
if (validator.isUUID(userIdentifier)) {
|
||||
@@ -51,8 +51,6 @@ api.getHero = {
|
||||
query = { 'auth.local.lowerCaseUsername': { $regex: re, $options: 'i' } };
|
||||
}
|
||||
|
||||
console.log(query);
|
||||
|
||||
const users = await User
|
||||
.find(query)
|
||||
.select('contributor backer profile auth')
|
||||
|
||||
Reference in New Issue
Block a user