@braintree/sanitize-url

A url sanitizer

Potential XSS vulnerability patched in v6.0.0.
Last updated 5 years ago by braintree .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @braintree/sanitize-url 
SYNC missed versions from official npm registry.

sanitize-url

Installation

npm install -S @braintree/sanitize-url

Usage

var sanitizeUrl = require("@braintree/sanitize-url").sanitizeUrl;

sanitizeUrl("https://example.com"); // 'https://example.com'
sanitizeUrl("http://example.com"); // 'http://example.com'
sanitizeUrl("www.example.com"); // 'www.example.com'
sanitizeUrl("mailto:hello@example.com"); // 'mailto:hello@example.com'
sanitizeUrl(
  "https&#0000058//example.com"
); // https://example.com

sanitizeUrl("javascript:alert(document.domain)"); // 'about:blank'
sanitizeUrl("jAvasCrIPT:alert(document.domain)"); // 'about:blank'
sanitizeUrl(decodeURIComponent("JaVaScRiP%0at:alert(document.domain)")); // 'about:blank'
// HTML encoded javascript:alert('XSS')
sanitizeUrl(
  "&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041"
); // 'about:blank'

Testing

This library uses Vitest. All testing dependencies will be installed upon npm install and the test suite can be executed with npm test. Running the test suite will also run lint checks upon exiting.

npm test

To generate a coverage report, use npm run coverage.

Current Tags

  • 7.1.2                                ...           latest (10 months ago)

27 Versions

  • 7.1.2                                ...           10 months ago
  • 7.1.1                                ...           2 years ago
  • 7.1.0                                ...           2 years ago
  • 7.0.4                                ...           2 years ago
  • 7.0.3                                ...           2 years ago
  • 7.0.2                                ...           3 years ago
  • 7.0.1                                ...           3 years ago
  • 7.0.0                                ...           3 years ago
  • 6.0.4                                ...           3 years ago
  • 6.0.3                                ...           3 years ago
  • 6.0.2                                ...           4 years ago
  • 6.0.1                                ...           4 years ago
  • 6.0.0                                ...           5 years ago
  • 5.0.2 [deprecated]           ...           5 years ago
  • 5.0.1 [deprecated]           ...           6 years ago
  • 5.0.0 [deprecated]           ...           6 years ago
  • 4.1.1 [deprecated]           ...           6 years ago
  • 4.1.0 [deprecated]           ...           6 years ago
  • 4.0.1 [deprecated]           ...           7 years ago
  • 4.0.0 [deprecated]           ...           7 years ago
  • 3.1.0 [deprecated]           ...           8 years ago
  • 3.0.0 [deprecated]           ...           8 years ago
  • 2.1.0 [deprecated]           ...           9 years ago
  • 2.0.2 [deprecated]           ...           9 years ago
  • 2.0.1 [deprecated]           ...           9 years ago
  • 2.0.0 [deprecated]           ...           9 years ago
  • 1.0.0 [deprecated]           ...           9 years ago
Maintainers (1)
Downloads
Total 29
Today 1
This Week 2
This Month 2
Last Day 0
Last Week 0
Last Month 27
Dependencies (0)
None
Dev Dependencies (8)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE