Skip to content

Commit

Permalink
Fixed waifu query using anime
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrea committed Mar 11, 2024
1 parent 8c35b25 commit d12f9d9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/controllers/v4/images/waifu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') } },
],
},
};
}

/**
Expand Down

0 comments on commit d12f9d9

Please sign in to comment.