16 lines
358 B
TypeScript
16 lines
358 B
TypeScript
import sanitizeHtml from 'sanitize-html';
|
|
|
|
const defaultSanitizeOptions = {
|
|
allowedTags: ['b', 'i', 'em', 'strong', 'a', 'ul', 'ol', 'li'],
|
|
allowedAttributes: {
|
|
'a': ['href', 'target']
|
|
}
|
|
}
|
|
|
|
export const sanitize = (dirty: string, options: sanitizeHtml.IOptions = defaultSanitizeOptions) => ({
|
|
__html: sanitizeHtml(
|
|
dirty,
|
|
options
|
|
)
|
|
});
|