rebase from live enviornment

This commit is contained in:
Rachit Bhargava
2024-01-09 22:14:20 -05:00
parent ff0b49a046
commit 3a22fcaa4a
15968 changed files with 2344674 additions and 45234 deletions

View File

@@ -0,0 +1,20 @@
/**
* External dependencies
*/
import DOMPurify from 'dompurify';
const ALLOWED_TAGS = [ 'a', 'b', 'em', 'i', 'strong', 'p', 'br' ];
const ALLOWED_ATTR = [ 'target', 'href', 'rel', 'name', 'download' ];
export const sanitizeHTML = (
html: string,
config?: { tags?: typeof ALLOWED_TAGS; attr?: typeof ALLOWED_ATTR }
) => {
const tagsValue = config?.tags || ALLOWED_TAGS;
const attrValue = config?.attr || ALLOWED_ATTR;
return DOMPurify.sanitize( html, {
ALLOWED_TAGS: tagsValue,
ALLOWED_ATTR: attrValue,
} );
};