Files
vault/ui/lib/core/addon/helpers/sanitized-html.js
2023-04-19 15:40:33 +00:00

15 lines
456 B
JavaScript

import { helper } from '@ember/component/helper';
import { debug } from '@ember/debug';
import { htmlSafe } from '@ember/template';
import { sanitize } from 'dompurify';
export default helper(function sanitizedHtml([htmlString]) {
try {
return htmlSafe(sanitize(htmlString));
} catch (e) {
debug('Error sanitizing string', e);
// I couldn't get this to actually fail but as a fallback render the value as-is
return htmlString;
}
});