When using JavaScript window.location in your code, be aware, that window.location is encoded using JavaScript escape function. It is not always obvious because characters, that get encoded / decoded using escape() / unescape() is rare in urls. Use the following syntax to get human readable url:
unescape(window.location)
URL: http://example.com/test url/
window.location: http://example.com/test%20url/
unescape(window.location): http://example.com/test url/
Also, HTTP POST must be percent encoded, using ‘+’ instead of ‘%20’:
w3
Percent encoding