Search code examples
apiencodingmocha.jssupertest

Diacritic chars encoding in API requests


I have one question about encoding diacritic chars in API request.

I can send via postman request GET /rest/city?query=Poznań, response is correct, in server logs city?query=Poznań is changed to city?query=Pozna%C5%84.

Also I have API test written in node.js (mocha, supertest) and here request GET /rest/city?query=Poznań return empty array, in server logs request method changed to GET /rest/city?query=PoznaD.

What's wrong with encoding in my API auto tests? Why ń changed to D? Do You know how can I changed this to fix issue.

Also in logs city?query=Łódz changes in changes in city?query=Aódz


Solution

  • Ok, i have solution, just city?query=${encodeURI(Łódź)}