Files
ai_platform/lib/strip-for-count.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

21 lines
614 B
JavaScript

/**
* HTML·태그·엔티티를 제외한 보이는 텍스트(글자 수 제한용)
* — sanitize-html 없이 사용해 서버 기동 시 모듈 누락으로 전체 앱이 죽는 것을 막습니다.
* @param {string} html
* @returns {string}
*/
function stripForCount(html) {
if (!html) return "";
return String(html)
.replace(/<style[\s\S]*?<\/style>/gi, " ")
.replace(/<script[\s\S]*?<\/script>/gi, " ")
.replace(/<[^>]+>/g, " ")
.replace(/&nbsp;/g, " ")
.replace(/&#[0-9]+;/g, " ")
.replace(/&[a-zA-Z0-9]+;/g, " ")
.replace(/\s+/g, " ")
.trim();
}
module.exports = { stripForCount };