0

A basic encoded URL would usually comprise of a "?" and few "&". Can this url be double encoded to eliminate all "?" and all the "&". would it work? Is it right to do it?

Please check a sample encoded url -

http://www.permadi.com/tutorial/urlEncoding/example.html?var=This+is+a+simple+%26+short+test&testmail=the+master.
anand patil
  • 507
  • 1
  • 9
  • 26
  • See [this](http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent) thread. – alesc Jun 26 '15 at 07:01

1 Answers1

0

Use encodeURIComponent, it will produce:

http%3A%2F%2Fwww.permadi.com%2Ftutorial%2FurlEncoding%2Fexample.html%3Fvar%3DThis%20is%20a%20simple%20%26%20short%20test%26testmail%3Dthe%20master.%20

It should works in all major browsers.

Kristian Vitozev
  • 5,791
  • 6
  • 36
  • 56
  • Thanks, it does encode as required. But tried accessing some stackoverflow urls after encoding using encodeURIComponent(complete stackover url). was not accessible! – anand patil Jun 26 '15 at 07:14