Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xss-mini

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xss-mini - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

dist/sanitizeHtml.min.js

7

package.json
{
"name": "xss-mini",
"version": "1.0.0",
"version": "1.0.1",
"description": "A lightweight library for sanitizing HTML input to prevent XSS attacks.",
"main": "dist/sanitizeHtml.js",
"main": "dist/sanitizeHtml.min.js",
"types": "dist/sanitizeHtml.d.ts",
"scripts": {
"build": "tsc",
"build": "tsc && terser dist/sanitizeHtml.js --compress --mangle --output dist/sanitizeHtml.min.js",
"test": "jest"

@@ -23,2 +23,3 @@ },

"jest-environment-jsdom": "^29.7.0",
"terser": "^5.31.1",
"ts-jest": "^29.1.5",

@@ -25,0 +26,0 @@ "ts-node": "^10.9.2",

@@ -17,21 +17,4 @@ # 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

@@ -61,4 +44,4 @@

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);
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);

@@ -65,0 +48,0 @@ console.log(safeHtml); // Outputs: <h1>Title</h1> <b>Hello</b> <a href="http://example.com">link</a>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc