Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "xss-mini", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A lightweight library for sanitizing HTML input to prevent XSS attacks.", | ||
@@ -21,3 +21,3 @@ "main": "dist/sanitizeHtml.min.js", | ||
], | ||
"author": "Your Name", | ||
"author": "Nathan McBride", | ||
"license": "MIT", | ||
@@ -24,0 +24,0 @@ "devDependencies": { |
@@ -5,3 +5,3 @@ # xss-mini | ||
[](https://github.com/brideo/xss-mini/actions) | ||
[](https://coveralls.io/github/brideo/xss-mini) | ||
[](https://coveralls.io/github/brideo/xss-mini) | ||
[](https://github.com/brideo/xss-mini/blob/main/LICENSE) | ||
@@ -18,4 +18,21 @@ [](https://david-dm.org/brideo/xss-mini) | ||
Or with yarn | ||
```bash | ||
yarn add xss-mini | ||
``` | ||
## Usage | ||
### In TypeScript | ||
```typescript | ||
import xss from 'xss-mini'; | ||
const userInput: string = '<h1>Title</h1> <b>Hello</b> <script>alert("XSS Attack!");</script> <a href="http://example.com" onclick="maliciousFunction()">link</a>'; | ||
const safeHtml: string = xss(userInput); | ||
console.log(safeHtml); // Outputs: <h1>Title</h1> <b>Hello</b> <a href="http://example.com">link</a> | ||
``` | ||
### In JavaScript | ||
@@ -45,4 +62,4 @@ | ||
const userInput = '<h1>Title</h1> <b>Hello</b> <script>alert("XSS Attack!");</script> <a href="http://example.com" onclick="maliciousFunction()">link</a>'; | ||
const safeHtml = xss(userInput, customAllowedTags, customAllowedAttributes); | ||
const userInput: string = '<h1>Title</h1> <b>Hello</b> <script>alert("XSS Attack!");</script> <a href="http://example.com" onclick="maliciousFunction()">link</a>'; | ||
const safeHtml: string = xss(userInput, customAllowedTags, customAllowedAttributes); | ||
@@ -49,0 +66,0 @@ console.log(safeHtml); // Outputs: <h1>Title</h1> <b>Hello</b> <a href="http://example.com">link</a> |
4934
4
69