From d12f9d9872361b5176d4af2bc2910637c2c70503 Mon Sep 17 00:00:00 2001 From: kyrea Date: Mon, 11 Mar 2024 20:15:15 +0530 Subject: [PATCH] Fixed waifu query using anime --- src/controllers/v4/images/waifu.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/v4/images/waifu.js b/src/controllers/v4/images/waifu.js index b62014c..785cc49 100644 --- a/src/controllers/v4/images/waifu.js +++ b/src/controllers/v4/images/waifu.js @@ -44,7 +44,14 @@ const getWaifu = async (req, res, next) => { if (anime) { const sanitizedAnime = _.escapeRegExp(anime.trim()); - filter['media.nodes[0].title.userPreferred'] = { $regex: new RegExp(sanitizedAnime, 'i') }; // Case-insensitive regex match for anime name + filter['media.nodes'] = { + $elemMatch: { + $or: [ + { 'title.userPreferred': { $regex: new RegExp(sanitizedAnime, 'i') } }, + { synonyms: { $regex: new RegExp(sanitizedAnime, 'i') } }, + ], + }, + }; } /**