@jorge-salgado/url-generator
v1.0.7
Published
This URL generator module allows you to sanitize any string and generate a URL-friendly version of it.
Downloads
6
Maintainers
Readme
URL Generator
How it works?
This URL generator module allows you to sanitize any string and generate a URL-friendly version of it.
You can use it to generate a URL-friendly version of any string, and it will remove all non-alphanumeric and special characters, protecting your application from any possible attacks like:
- XSS (Cross-site scripting)
- SQL injection
The folling characters will be remove:
|°¬!"#$%&/()=?'\¿¡´¨+~{}[]^`,;.:_@<>
Getting started
- Install the module:
npm i @jorge-salgado/url-generator
- Use the module:
const URL_GENERATOR = require('@jorge-salgado/url-generator');
URL_GENERATOR('String To Sanitize <script>alert(document.cookie)</script>');
//OUTPUT: 'string-to-sanitize-scriptalertdocumentcookiescript'
Or if you prefer it, you can use the modules individually
Sanitizer
const SANITIZER = require('@jorge-salgado/url-generator/modules/sanitizer');
SANITIZER('string to sanitize <script>alert(document.cookie)</script>');
//OUTPUT: 'string to sanitize scriptalertdocumentcookiescript'
URL Pattern
const URL_PATTERN = require('@jorge-salgado/url-generator/modules/urlPattern');
URL_PATTERN('String To Sanitize');
//OUTPUT: 'string-to-sanitize'