'&' sign in game names causing query issue

Hi

The ‘Music’ category got renamed to ‘Music & Performing Arts’, now if i query the user’s followed games

"name": "Music & Performing Arts",

It’s clearly named as it is. If i query that game name, i get nothing back. Meanwhile if i go to the same category on the same site:

https://www.twitch.tv/directory/game/Music %26 Performing Arts

The & sign magically turns into %26, so if i query again with %26 instead of &, i get the correct information.

I know why it’s %26, the question is, is this intended behavior? Do i have to manually replace the ‘&’ sign to %26. From my point of view, the API should supply the right data, so imo this is a bug.

That’s not a bug, that’s intentional. The ampersand & is used to separate parameters in a querystring, which is why it, along with other special characters, can’t be contained in the parameter field or value. As such, it has to be properly URL encoded. This is just standard practice, many HTTP request libraries can do URL encoding/decoding automatically.

1 Like

The API returns the correct game name. It is on you to sanitize that value for your use-case. In this case, URL encode it before inserting it into a URL.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.