UNPKG

@n3okill/utils

Version:
22 lines 506 B
import { isNullOrUndefined } from "../type/isNullOrUndefined"; /** * @internal */ const EncodeHtmlRules = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&#34;", "'": "&#39;", }; /** * Escape html string * @param arg */ export function escapeHtml(arg) { return isNullOrUndefined(arg) ? "" : // eslint-disable-next-line security/detect-object-injection arg.replace(/[&<>'"]/g, (c) => EncodeHtmlRules[c] || c); } //# sourceMappingURL=escapeHtml.js.map