Skip to content

Commit e69516a

Browse files
committed
Added check that the part after comma is actually area or country
1 parent a8407c2 commit e69516a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Sources/App/GeocodingapiController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ struct GeocodingapiController: RouteCollection {
6363
name = parts[0].trimmingCharacters(in: .whitespacesAndNewlines)
6464
let areaName = parts[1].trimmingCharacters(in: .whitespacesAndNewlines)
6565
if areaName.count > 1 {
66-
areaIds = database.search(areaName, languageId: Int32(languageId), maxCount: 10).map({
66+
areaIds = database.search(areaName, languageId: Int32(languageId), maxCount: 10).compactMap({
67+
guard ["ADM1","ADM2","ADM3","ADM4","PCLI"].contains(database.geonames.geonames[$0.0]?.featureCode) else {
68+
return nil
69+
}
6770
return $0.0
6871
})
6972
}

0 commit comments

Comments
 (0)