1.3.3 ⢠Published 10 months ago
@jill64/universal-sanitizer v1.3.3
@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
// }
})
condition | resolve |
---|---|
browser | DOMPurify |
default | sanitize-html |
worker | sanitize-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
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