supermario / elm-countries

elm-countries package
http://package.elm-lang.org/packages/supermario/elm-countries/latest/Countries
MIT License
17 stars 4 forks source link

Bug in searchCustom #9

Closed MedeaMelana closed 3 years ago

MedeaMelana commented 3 years ago

From reading the source code of searchCustom, I noticed what I think is a bug: by checking if the query is a substring of country.name ++ country.code, you'd get Andorra (and a few other countries) as a result for query "aa" even though no "aa" appears in either the country name or code individually. For query "aa" I would expect "Sint Maarten (Dutch part)" to be the only result.

supermario commented 3 years ago

Hey @MedeaMelana - thanks for reporting this!

The searchCustom function isn't supposed to be super intelligent, just a quick utility, but you make a good point.

Would country.name ++ " " ++ country.code behave more consistently for your expectations?

MedeaMelana commented 3 years ago

Hi @supermario, no I think the right way to do it is:

\country ->
    String.contains (String.toLower searchString) (String.toLower country.name) ||
    String.contains (String.toLower searchString) (String.toLower country.code)
supermario commented 3 years ago

Cool, that makes sense.

This change is released in v1.1.1, thanks @MedeaMelana !