1.0.9 ā€¢ Published 2 days ago

universal-dompurify v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

universal-dompurify

šŸ’Ž Use DOMPurify for some context by conditional exports

Installation

npm i universal-dompurify

Usage

Conditional exports apply the appropriate DOMPurify file at each run.

import DOMPurify from 'universal-dompurify'

const cleaned = DOMPurify.sanitize(/* ... */)
conditionresolve
browserDOMPurify
defaultDOMPurify + JSDOM
workerDOMPurify + JSDOM + (require: your external node polyfills)

!TIP It is generally not recommended to use JSDOM with the restricted Edge runtime.
See also @jill64/universal-sanitizer for a more lightweight alternative.

Browser Only Mode

Reduces bundle size by omitting rendering on the server.

/** @type {DOMPurify | null} */
import DOMPurify from 'universal-dompurify/browser-only'

const cleaned = DOMPurify?.sanitize?.(/* ... */) ?? 'server-fallback-value'
conditionresolve
browserDOMPurify
defaultnull
workernull

License

MIT

1.0.9

2 days ago

1.0.8

21 days ago

1.0.7

1 month ago

1.0.6

1 month ago

1.0.5

2 months ago

1.0.4

3 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

5 months ago

0.4.1

5 months ago

0.4.0

5 months ago

0.3.0

5 months ago

0.2.0

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago

0.0.1

5 months ago