Escapes HTML entities to make a string HTML safe

export const HTMLSafe = function (str: string): string {
return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
};
  • Parameters

    • str: string

      The string to escape

    Returns string

    A new string with HTML entities escaped