Complexity Score
Low
Open Issues
N/A
Dependent Projects
75
Weekly Downloadsglobal
2,043,858
License
- MIT
- Yesattribution
- Permissivelinking
- Permissivedistribution
- Permissivemodification
- Nopatent grant
- Yesprivate use
- Permissivesublicensing
- Notrademark grant
Downloads
Readme
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
.
Dependencies
Loading dependencies...
CVE IssuesActive
0
Scorecards Score
3.80
Test Coverage
No Data
Follows Semver
Yes
Github Stars
334
Dependenciestotal
11
DependenciesOutdated
8
DependenciesDeprecated
0
Threat Modelling
No Data
Repo Audits
No Data
Learn how to distribute @braintree/sanitize-url in your own private NPM registry
$npm config set registry
https://npm.cloudsmith.com/owner/repo
/Processing...
✓Done
$npm install @braintree/sanitize-url
/Processing...
✓Done
26 Releases
NPM on Cloudsmith