BellCubeDev/full-uri-escaper

Encodes every character of a passed string with its URI percent-encoded counterpart—even characters that are already URI-safe

★ 0Forks 0TypeScriptGitHub ↗Compare

README

Full URI Escaper

This is a simple Node package to replace every character in a string with its URI-escaped equivalent. It can be used, for instance, to somewhat obfuscate query string parameters in a URI, for instance.

full-uri-escaper is designed to run both in the browser and in Node.

Usage Examples

Directly log escaped string

import fullURIEscaper from 'full-uri-escaper';

// log `escaped` to the console
console.log( fullURIEscaper('Whatever you say, Mr. Boss-man!') );

Output:

%57%68%61%74%65%76%65%72%20%79%6f%75%20%73%61%79%2c%20%4d%72%2e%20%42%6f%73%73%2d%6d%61%6e%21

Get input from STDIN

import fullURIEscaper from 'full-uri-escaper';

// Request user input and set the STDIN to a variable so we can manipulate it
const stdin = fullURIEscaper.requestInput()

// End the STDIN on input, effectively only allowing one input
stdin.on('data', () => {  stdin.end()  });

Examples of STDOUT output:

EXAMPLE OUTPUT: "Enter a string to encode:"

EXAMPLE OUTPUT: Enter a string to encode:
Whatever you say, Mr. Boss-man!
%57%68%61%74%65%76%65%72%20%79%6f%75%20%73%61%79%2c%20%4d%72%2e%20%42%6f%73%73%2d%6d%61%6e%21

Enter a string to encode:

From Command Line

npx full-uri-escaper "Whatever you say, Mr. Boss-man!"
full-uri-escaper "Whatever you say, Mr. Boss-man!"

Examples of CLI output:

npx full-uri-escaper "Whatever you say, Mr. Boss-man!"
%57%68%61%74%65%76%65%72%20%79%6f%75%20%73%61%79%2c%20%4d%72%2e%20%42%6f%73%73%2d%6d%61%6e%21

Contributors

BellCubeDev

Issues