Properly encode the url in javascript