encode url javascript code example
Example 1: urlencode javascript
var url = encodeURIComponent('url');
Example 2: js urlencode
/* There are 11 characters which are not encoded by encodeURI,
but encoded by encodeURIComponent. */
encodeURI("test uri");
// "test%20uri"
encodeURI("test uri");
// "test%20uri"
encodeURI("test uri/with a slash");
// "test%20uri/with%20a%20slash"
encodeURIComponent("test uri/with a slash");
// "test%20uri%2Fwith%20a%20slash"
Example 3: type script encode url
var encodeURI = encodeURIComponent("&")
Example 4: jq unencode string
# -r enable raw output
jq -r .[0].string FILE.json