phpurlencode
Functionally similar to PHP urlencode and urldecode functions. No dependencies.
Install
NPM
$ npm install phpurlencode
Yarn
$ yarn add phpurlencode
Usage
Include it in your Node.js file
var phpurlencode = require('phpurlencode');
phpurlencode(string)
var encodedString = phpurlencode("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.67 Safari/537.36");
console.log(encodedString);
phpurlencode.encode(string) [ alias of phpurlencode( ) ]
var encodedString = phpurlencode.encode("!@#$%^&*()-+='\"");
console.log(encodedString);
phpurlencode.decode(string)
var decodedString = phpurlencode.decode('%21%40%23%24%25%5E%26%2A%28%29-%2B%3D%27%22');
console.log(decodedString);
phpurlencode.definePrototypes()
Globally defines .urlencode
and .urldecode
String prototypes
phpurlencode.definePrototypes();
var decodedString = '%21%40%23%24%25%5E%26%2A%28%29-%2B%3D%27%22'.urldecode();
console.log(decodedString);
var encodedString = decodedString.urlencode();
console.log(encodedString);