I have been testing the musicbrainz API and I found a problem for me. When the title has an '&' in the name the query returns the wrong results. For example: The title is 'auf & ab' and the query returns a title named 'auf, auf, auf'.
I sort of fixed this by replacing '&' with 'and' like this:
if (title.includes('&')){title = title.replace('&','and')}
This returns the correct results. I am not sure if this is the way to solve this issue. This is my query: https://musicbrainz.org/ws/2/recording/?query=recording:auf & ab && artist:montez&fmt=json&limit=5
CodePudding user response:
I think you need to encode the "space" (with ) and the "&" (with &) chars, since they are used in url the & will be decoded as another new parameter in query string; try with this:
https://musicbrainz.org/ws/2/recording/?query=recording:auf & ab&artist:montez&fmt=json&limit=5
In this way, your search "auf & ab" -> "auf & ab"; you can achieve this result using the encodeURIComponent("auf & ab")
Edit: changed encodeURI -> encodeURIComponent