UNPKG

751 BJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5const unescape_html_1 = __importDefault(require("./unescape_html"));
6const htmlEntityMap = {
7 '&': '&',
8 '<': '&lt;',
9 '>': '&gt;',
10 '"': '&quot;',
11 '\'': '&#39;',
12 '`': '&#96;',
13 '/': '&#x2F;',
14 '=': '&#x3D;'
15};
16function escapeHTML(str) {
17 if (typeof str !== 'string')
18 throw new TypeError('str must be a string!');
19 str = (0, unescape_html_1.default)(str);
20 // http://stackoverflow.com/a/12034334
21 return str.replace(/[&<>"'`/=]/g, a => htmlEntityMap[a]);
22}
23module.exports = escapeHTML;
24//# sourceMappingURL=escape_html.js.map
\No newline at end of file