@sanitise/uri
v0.1.1
Published
🧼 Sanitise a URI to mitigate XSS and malformed URIs
Downloads
43
Readme
@sanitise/uri
🧼 Sanitise a URI to mitigate XSS and malformed URIs
Requirements
This module requires an Active LTS Node version (v14.15.0+).
Install
Using npm:
npm install @sanitise/uri
Usage
const { sanitise } = require('@sanitise/uri');
sanitise('http://bat.cave');
// → 'http://bat.cave'
sanitise(`javascript:alert('joker')`);
// → undefined
Falsey Results
This package follows the behavior of JSON.stringify
. The following results for falsey values can be expected:
sanitise(undefined);
// → undefined
sanitise(null);
// → 'null'
sanitise('');
// → ''
Options
invalidUri
Type: String
Default: ''
Sets the default result value, should the uri
passed contain an invalid protocol.