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);
|
||||
} else {
|
||||
doc.forEach((value) => {
|
||||
if(value.city.search(regex) !== -1){
|
||||
cities.add(value.city);
|
||||
}
|
||||
if(value.name.search(regex) !== -1){
|
||||
restaurants.add(value.name);
|
||||
}
|
||||
});
|
||||
res.send({
|
||||
cities: Array.from(cities),
|
||||
@@ -93,7 +97,7 @@ router.get("/autocomplete/", (req, res) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
).limit(5);
|
||||
).limit(10);
|
||||
} else {
|
||||
res.send({
|
||||
cities: [],
|
||||
|
||||
Reference in New Issue
Block a user