123456789101112131415161718192021 |
- "use strict"
- /* istanbul ignore file */
- function getEncodeHtml() {
- const encodeHTMLRules = {
- "&": "&",
- "<": "<",
- ">": ">",
- '"': """,
- "'": "'",
- "/": "/",
- }
- const matchHTML = /&(?!#?\w+;)|<|>|"|'|\//g
- return function encodeHtml(s) {
- return typeof s === "string" ? s.replace(matchHTML, (m) => encodeHTMLRules[m] || m) : s
- }
- }
- module.exports = getEncodeHtml
|