@n3okill/utils
Version:
Many javascript helpers
22 lines • 506 B
JavaScript
import { isNullOrUndefined } from "../type/isNullOrUndefined";
/**
* @internal
*/
const EncodeHtmlRules = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
};
/**
* 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