( message: string, allowedTags = ['b', 'strong', 'br'], allowedAttributes = ['class'], )
| 9 | * Sanitizes HTML string and allows only bold tags |
| 10 | */ |
| 11 | export const sanitizeMessage = ( |
| 12 | message: string, |
| 13 | allowedTags = ['b', 'strong', 'br'], |
| 14 | allowedAttributes = ['class'], |
| 15 | ): string => { |
| 16 | // Only run on client-side |
| 17 | if (typeof window === 'undefined') { |
| 18 | return message; |
| 19 | } |
| 20 | |
| 21 | const purify = createDOMPurify(window); |
| 22 | |
| 23 | return purify.sanitize(message, { |
| 24 | ALLOWED_TAGS: allowedTags, |
| 25 | ALLOWED_ATTR: allowedAttributes, |
| 26 | }); |
| 27 | }; |
| 28 | |
| 29 | const brokenWebviewPatterns = [ |
| 30 | /FBAN|FBAV/i, // Facebook App |
no outgoing calls
no test coverage detected