16 lines
354 B
TypeScript
16 lines
354 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),
|
|
});
|