I face a problem with encoding URL query, in my application it's search URL. For example, here is a peace of code:
url_path = 'http://ift.tt/1ALMoLX' + search_phrase;
Yes, I can use method encodeURIComponent() and it works:
url_path = 'http://ift.tt/1ALMoLX' + encodeURIComponent(search_phrase);
But when user search for a phrase which include symbols like '%' - it generates broken request. And in results I have 500 response with error:
URIError: malformed URI sequence
How can I encode URI parameters to prevent current problem? If I am wrong in something or don't understand correctly how it works, please explain me it. Kindly thanks for help.
Aucun commentaire:
Enregistrer un commentaire