Skip to content

Commit

Permalink
only lower $translatedRegion once for 3 comparisons.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasVHG committed Aug 22, 2024
1 parent bd37de0 commit fd2162b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Widget/RegionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ public function getAutocompletResults($searchString, $language = 'nl')
$translatedRegion = $region->name;
}
}
$compareString = strtolower($translatedRegion);
// This is done to find cities & towns with short names which also match lots of other cities & towns
// e.g., Zele or Egem
if (strpos(strtolower($translatedRegion), $searchString) === 0) {
if (strpos($compareString, $searchString) === 0) {
$matches[$region->key] = $translatedRegion;
}
// This is done to add the submunicipalities when searching for a municipality.
if (strpos(strtolower($translatedRegion), '(' . $searchString) !== false) {
if (strpos($compareString, '(' . $searchString) !== false) {
$matches[$region->key] = $translatedRegion;
}
// This is done to add informal municipality names without prefixes like Saint
if (strpos(strtolower($translatedRegion), '-' . $searchString) !== false) {
if (strpos($compareString, '-' . $searchString) !== false) {
$matches[$region->key] = $translatedRegion;
}
}
Expand Down

0 comments on commit fd2162b

Please sign in to comment.