1.3.3 • Published 10 months ago

@jill64/universal-sanitizer v1.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@jill64/universal-sanitizer

šŸ’Ž 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

1.3.3

10 months ago

1.3.2

10 months ago

1.3.1

11 months ago

1.3.0

1 year ago

1.2.12

1 year ago

1.2.13

1 year ago

1.2.14

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago