Percentage of encoding in window.location

When I open the URL with special characters using window.location, it seems to encode special characters and then open the URL. for instance

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

This will open a page with a URL:

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

instead:

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

How to open URL correctly without percent encoded characters

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

+4
source share
2 answers

I do not believe the problem is with Windows.location and your JavaScript. The problems are rather related to the way 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 remain unchanged.

Now try entering http://gramfeed.com/instagram/tags/kühl directly in the address bar of your browser - the URL will be converted.

+3
source

I also ran into this problem, but it was a completely different problem, although the symptoms were the same. As a result, it turned out that I was redirected to the desktop URL, but for mobile phones it was redirected to their server on their mobile site, and that was when he received the encoding twice.

Therefore, it is always worth trying to redirect to a mobile site, if possible, and on a mobile phone.

Hope this helps someone else :)

0
source

Source: https://habr.com/ru/post/1499001/


All Articles