Files
ai_platform/lib/sanitize-use-case-body.js
dsyoon 073a8343dd feat: xavis ai_platform 기능 이전 및 ncue 환경 전환
xavis 소스·DB 스키마·활용사례/F-Scan/프롬프트 라이브러리 등 기능 반영.
@xavis.co.kr → @ncue.net, 관리자 토큰 ncue-admin, 런타임 data/ Git 추적 제외.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 22:27:48 +09:00

66 lines
1.1 KiB
JavaScript

const sanitizeHtml = require("sanitize-html");
const SANITIZE_OPTIONS = {
allowedTags: [
"p",
"br",
"div",
"span",
"strong",
"b",
"em",
"i",
"u",
"s",
"del",
"strike",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"ul",
"ol",
"li",
"blockquote",
"pre",
"code",
"hr",
"a",
"table",
"thead",
"tbody",
"tfoot",
"tr",
"th",
"td",
],
allowedAttributes: {
a: ["href", "target", "rel", "name"],
th: ["colspan", "rowspan", "align"],
td: ["colspan", "rowspan", "align"],
},
allowedSchemes: ["http", "https", "mailto", "tel"],
transformTags: {
a: (tagName, attribs) => {
const next = { ...attribs };
if (next.target === "_blank") {
next.rel = (next.rel || "noopener") + (next.rel && next.rel.indexOf("noreferrer") >= 0 ? "" : " noreferrer");
}
return { tagName, attribs: next };
},
},
};
/**
* @param {string} html
* @returns {string}
*/
function sanitizeUseCaseBody(html) {
if (html == null) return "";
return sanitizeHtml(String(html), SANITIZE_OPTIONS);
}
module.exports = { sanitizeUseCaseBody };