UNPKG

@n3okill/utils

Version:
25 lines 637 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.escapeHtml = escapeHtml; const isNullOrUndefined_1 = require("../type/isNullOrUndefined"); /** * @internal */ const EncodeHtmlRules = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&#34;", "'": "&#39;", }; /** * Escape html string * @param arg */ function escapeHtml(arg) { return (0, isNullOrUndefined_1.isNullOrUndefined)(arg) ? "" : // eslint-disable-next-line security/detect-object-injection arg.replace(/[&<>'"]/g, (c) => EncodeHtmlRules[c] || c); } //# sourceMappingURL=escapeHtml.js.map