Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Percent encoding in window.location

When I open a url with special characters using window.location, it seems to percent encode the special characters and then opens the URL. For example

var url = "http://gramfeed.com/instagram/tags/kühl";
window.location = url;

This will result in opening a page with URL:

http://gramfeed.com/instagram/tags/k%C3%BChl

instead of:

http://gramfeed.com/instagram/tags/kühl

How do I make the URL open correctly without percent encoded characters

Here is a jsfiddle to play with the code: http://jsfiddle.net/krisrak/aSkMR/

like image 740
krisrak Avatar asked Oct 22 '22 02:10

krisrak


1 Answers

I do not believe the problem is with windows.location and your JavaScript. The problems is rather with how gramfeed.com interprets tags. Try this in your code:

var url = "https://www.google.com/search?q=kühl"
window.location = url;

See that special characters stay unconverted.

Now try typing http://gramfeed.com/instagram/tags/kühl directly in browser address bar - the URL gets converted.

like image 108
Yuriy Galanter Avatar answered Nov 03 '22 03:11

Yuriy Galanter