elamperti / OpenWebScrobbler

🎧 An open source web scrobbler for Last.fm
https://openscrobbler.com/
GNU General Public License v2.0
323 stars 37 forks source link

Some research fails due to some particular characters as the `.` #83

Closed silversonicaxel closed 5 years ago

silversonicaxel commented 5 years ago

Describe the bug Some particular types of album/artist search are not working properly, maybe due to special characters as . or else.

Steps to reproduce

  1. Go to album / artist search page https://openscrobbler.com/scrobble/album
  2. Type the name of this Icelandic artist dj. flugvél og geimskip
  3. No albums or no artists are shown

Expected behavior Albums and artist related to the search dj. flugvél og geimskip should appear

Device

Platform (please complete the following information):

Additional context The network tab of the browser dev area shows that API call return correctly the results, so error is within the javascript code. The search of flugvél og geimskip returns results correctly. That's the reason of the assumption of special characters as cause of the bug.

elamperti commented 5 years ago

Thanks for this detailed report! I was able to find the source of this error: when the search query (or the artist or the album name) contained periods, the lodash get() was interpreting them as a separator between an object dj and a key flugvél og geimskip. This was solved properly escaping the query string by referencing it inside quotes, e.g.:

myObject.get(data, `foo['${query}'].bar`)

This can be seen more clearly in the commit fea8420, which solves this issue.

I also improved on how the artists were being referenced, as sometimes the searches would show empty results when the artist didn't have an mbid.

silversonicaxel commented 5 years ago

Well done Enrico!