Files
TechRadarAJR/src/sanitize.ts
2022-09-13 11:28:06 +02:00

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),
});