@n3okill/utils
Version:
Many javascript helpers
25 lines • 637 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.escapeHtml = escapeHtml;
const isNullOrUndefined_1 = require("../type/isNullOrUndefined");
/**
* @internal
*/
const EncodeHtmlRules = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
};
/**
* 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
;