Description
Hi,
I only recently discovered the iRail website (after finding out about the recent developments in open-data at NMBS), nice work!
Although, while looking around on the website I noticed some weird behavior while using the type-ahead feature.
For example: when searching for station Ekeren, typing in the first 2 letters 'Ek' results in a list showing:
- Schaarbeek/Schaerbeek
- Etterbeek
- Lebbeke
- Dilbeek
- Essene-Lombeek
- Brussels-Chapelle/Brussels-Kapellekerk
Not really what i was looking for ...
As chances are slim that someone would try finding his/her destination station by typing some of its middle letters, this behavior sort of makes the type-ahead feature useless imho.
I traced this behavior down to the regex filter in the iRail/stations repo.
Some fiddling around with the regexp (I'm far from a regex-wizard ...) shows that changing '/.*'.$query.'.*/i'
to '/.*\\b'.$query.'.*/i'
would drastically improve accuracy (for the hyperrail use-case).
Typing 'Ek' would result in:
- Ekeren
- Eke-Nazareth
Although I'm aware that you may want to keep the 'broad-search' functionality in the stations api, there's some room for improvement for it's use in the hyperrail-app ...
I'd be happy to file a pull-request after hearing some thoughts on this ...
Michaël