sly-utils
Version:
sly-utils is a modular and efficient JavaScript utility library designed to simplify complex tasks.
27 lines (26 loc) • 651 B
TypeScript
/**
* This method sanitizes the user input in HTML templates to prevent
* XSS attacks.This technique ensures that user-generated content is
* safely inserted into the DOM without executing any malicious scripts.
* @param {string} String with HTML tags
* @returns {string} String with HTML entities
*
* @example
*
* escapeHtml('AT&T');
* // => AT&T
*
* escapeHtml('<div>');
* // => <div>
*
* escapeHtml('</div>');
* // => </div>
*
* escapeHtml("O'Reilly");
* // => O'Reilly
*
* escapeHtml('He said, "Hello"');
* // => He said, "Hello"
*
*/
export declare const escapeHtml: (str: string) => string;