From 9b2de7591077bab18f8c3ee9ecf88d69848dfae9 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Thu, 8 Oct 2020 23:41:18 +0200 Subject: [PATCH] Received and searched names are lowercased. Endpoint /lottery/by-name now lowercases the path input name and the search query towards mongo. --- api/lottery.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/lottery.js b/api/lottery.js index 17d8e29..7331990 100644 --- a/api/lottery.js +++ b/api/lottery.js @@ -98,8 +98,9 @@ const byEpochDate = (req, res) => { const byName = (req, res) => { const { name } = req.params; + const regexName = new RegExp(name, "i"); // lowercase regex of the name - return Highscore.find({ name }) + return Highscore.find({ "name": { $regex : regexName } }) .then(async (highscore) => { highscore = highscore[0] if (highscore) {