🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@jill64/universal-sanitizer

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jill64/universal-sanitizer

đź’Ž Isomorphic html sanitizer by DOMPurify + sanitize-html

latest
Source
npmnpm
Version
1.4.6
Version published
Weekly downloads
2.9K
-0.88%
Maintainers
1
Weekly downloads
 
Created
Source

@jill64/universal-sanitizer

npm-version npm-license npm-download-month npm-min-size ci.yml

đź’Ž Isomorphic html sanitizer by DOMPurify + sanitize-html

Installation

npm i @jill64/universal-sanitizer

Usage

Conditional Export applies the appropriate file at each runtime.

import { sanitize } from '@jill64/universal-sanitizer'

const cleaned = sanitize(/* ... */, {
  // options: {
  //   sanitizeHtml: sanitize-html options
  //   dompurify: DOMPurify options
  // }
})
conditionresolve
browserDOMPurify
defaultsanitize-html
workersanitize-html

Add DOMPurify hook

The hook is executed before sanitize

import { sanitize } from '@jill64/universal-sanitizer'

const cleaned = sanitize(/* ... */, {
  options: {
    hook: (DOMPurify) => {
      DOMPurify.addHook(
        'uponSanitizeAttribute',
        function (currentNode, hookEvent, config) {
          // Do something with the current node
          // You can also mutate hookEvent for current node (i.e. set hookEvent.forceKeepAttr = true)
          // For other than 'uponSanitizeAttribute' hook types hookEvent equals to null
        }
      )
    }
  }
})

License

MIT

Keywords

dom

FAQs

Package last updated on 14 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts