UNPKG

litenode

Version:

Lightweight and modular web framework

12 lines (10 loc) 201 B
export function escapeHtml(str) { const escapeMap = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;", } return str.replace(/[&<>"']/g, (match) => escapeMap[match]) }