Encode URL Query String

To put a text secure into the url query you have to escape / encode it before.


Libraries

Code Snippet
escape("Text to escape");  // will not encode: @*/+
encodeURI("Text to escape");  // will not encode: ~!@#$&*()=:/,;?+'
encodeURIComponent("Text to escape");  // will not encode: ~!*()'


Implementation

I recommend to use escape. Some tests:<code>escape("Text to escape"); // Text%20to%20escape escape("Hello {[( =$%&/"); // Hello%20%7B%5B%28%20%3D%24%25%26/ escape("\!§³²~ä?"); // %21%A7%B3%B2%7E%E4%3F</code>





Comments
  • mode_editWrite a comment



  • forumComments




Embed Code

We provide special containers which include the full snippet and a link to this site. So for example when you make a tutorial and you are using code from this site, you can use one of the following snippet embeddings:

Load Preview Get Code Close Preview







    Share
    Rating
    thumb_up 0 thumb_down
    Author
    Thorolus

    I'm the head developer and co-founder of GlovilGames Studios (glovilgames.com) and other platforms GlovilGames created, like vsnippets.com, worth-calculator.net, python-obfuscator.com and some mobile apps and games.

    Tags
    Security



    Informations

    posted on 2016-09-16 19:19:23

    viewed 27 times

    snippet's UUID is 57dc299b9802e

    Similar Snippets