Autocomplete fix
Fixed autocomplete returning both city and name if any of them matched regex
This commit is contained in:
@@ -84,8 +84,12 @@ router.get("/autocomplete/", (req, res) => {
|
|||||||
res.sendStatus(404);
|
res.sendStatus(404);
|
||||||
} else {
|
} else {
|
||||||
doc.forEach((value) => {
|
doc.forEach((value) => {
|
||||||
cities.add(value.city);
|
if(value.city.search(regex) !== -1){
|
||||||
restaurants.add(value.name);
|
cities.add(value.city);
|
||||||
|
}
|
||||||
|
if(value.name.search(regex) !== -1){
|
||||||
|
restaurants.add(value.name);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
res.send({
|
res.send({
|
||||||
cities: Array.from(cities),
|
cities: Array.from(cities),
|
||||||
@@ -93,7 +97,7 @@ router.get("/autocomplete/", (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).limit(5);
|
).limit(10);
|
||||||
} else {
|
} else {
|
||||||
res.send({
|
res.send({
|
||||||
cities: [],
|
cities: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user