0.1.1 โ€ข Published 3 years ago

@sanitise/uri v0.1.1

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
3 years ago

size openbase libera manifesto

@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.

Meta

CONTRIBUTING

LICENSE (MIT)