Escapes special HTML characters in a string to prevent XSS attacks.

Replaces characters such as &, <, >, ", and ' with their HTML-escaped equivalents.

  • Parameters

    • text: string

      The text to escape.

    Returns string

    The escaped version of the input text.