7.0.1 • Published 1 month ago
@braintree/sanitize-url v7.0.1
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://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(
"javascript:alert('XSS')"
); // '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
.
7.0.1
1 month ago
7.0.0
5 months ago
6.0.3
9 months ago
6.0.4
9 months ago
6.0.1
2 years ago
6.0.2
1 year ago
6.0.0
2 years ago
5.0.2
3 years ago
5.0.1
3 years ago
5.0.0
4 years ago
4.1.1
4 years ago
4.1.0
4 years ago
4.0.1
4 years ago
4.0.0
5 years ago
3.1.0
5 years ago
3.0.0
5 years ago
2.1.0
6 years ago
2.0.2
7 years ago
2.0.1
7 years ago
2.0.0
7 years ago
1.0.0
7 years ago