/** * Escapes HTML special characters to prevent XSS. * @param {string} str The string to escape. * @returns {string} The escaped string. */ export function escapeHtml(str) { return str .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); }