1.4.6 ⢠Published 7 months ago
@jill64/universal-sanitizer v1.4.6
@jill64/universal-sanitizer
š Isomorphic html sanitizer by DOMPurify + sanitize-html
Installation
npm i @jill64/universal-sanitizerUsage
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.4.6
7 months ago
1.4.5
7 months ago
1.3.6
11 months ago
1.4.4
8 months ago
1.3.5
12 months ago
1.4.3
8 months ago
1.3.4
1 year ago
1.4.2
9 months ago
1.4.1
10 months ago
1.4.0
11 months ago
1.3.3
1 year ago
1.3.2
1 year ago
1.3.1
1 year ago
1.3.0
1 year ago
1.2.12
2 years ago
1.2.13
2 years ago
1.2.14
1 year ago
1.2.11
2 years ago
1.2.10
2 years ago
1.2.9
2 years ago
1.2.8
2 years ago
1.2.7
2 years ago
1.2.6
2 years ago
1.2.5
2 years ago
1.2.4
2 years ago
1.2.3
2 years ago
1.2.2
2 years ago
1.2.1
2 years ago
1.2.0
2 years ago
1.1.1
2 years ago
1.1.0
2 years 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