Received and searched names are lowercased.

Endpoint /lottery/by-name now lowercases the path input name and the
search query towards mongo.
This commit is contained in:
2020-10-08 23:41:18 +02:00
committed by KevinMidboe
parent 05b07ca465
commit 9b2de75910

View File

@@ -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) {