Sifa professional network frontend (Next.js, React, TailwindCSS)
sifa.id/
1import DOMPurify from 'isomorphic-dompurify';
2
3export function sanitize(input: string): string {
4 return DOMPurify.sanitize(input, { ALLOWED_TAGS: [] });
5}
6
7/** Sanitize HTML produced by react-markdown — allows safe formatting tags only. */
8export function sanitizeMarkdownHtml(input: string): string {
9 return DOMPurify.sanitize(input, {
10 ALLOWED_TAGS: [
11 'p',
12 'br',
13 'strong',
14 'b',
15 'em',
16 'i',
17 'a',
18 'ul',
19 'ol',
20 'li',
21 'code',
22 'pre',
23 'blockquote',
24 'h1',
25 'h2',
26 'h3',
27 'h4',
28 'h5',
29 'h6',
30 ],
31 ALLOWED_ATTR: ['href', 'target', 'rel'],
32 });
33}