// @ts-ignore
import _escapeHtml from "escape-html"
import type { IFilterXSSOptions } from "xss"
import _xss from "xss"
/**
* 转义 HTML 代码,使其可以插入到 HTML 中显示。
* @example
* escapeHtml("
123
") // "<div>123</div>"
*/
export function escapeHtml(html: string): string {
return _escapeHtml(html)
}
/**
* 对 HTML进行 XSS 过滤
* 与 escapeHtml 不同,xss 只会转义危险的 HTML 内容,如 script 标签,而不会转义普通的 HTML 标签
* @example
* xss("123
") // "123<script>alert('xss')</script>
"
*/
export function xss(html: string, options?: IFilterXSSOptions): string {
return _xss(html, options)
}