Allow searching by partial prefix (/w or /wo '+')

pull/21833/head
Luke Barnard 2017-05-18 17:01:40 +01:00
parent a425909b76
commit 384f50609d
1 changed files with 6 additions and 1 deletions

View File

@ -26,9 +26,14 @@ for (const c of COUNTRIES) {
}
function countryMatchesSearchQuery(query, country) {
// Remove '+' if present (when searching for a prefix)
if (query[0] === '+') {
query = query.slice(1);
}
if (country.name.toUpperCase().indexOf(query.toUpperCase()) == 0) return true;
if (country.iso2 == query.toUpperCase()) return true;
if (country.prefix == query) return true;
if (country.prefix.indexOf(query) !== -1) return true;
return false;
}