UNPKG

@squirrel-forge/ui-util

Version:

A collection of utilities, classes, functions and abstracts made for the browser and babel compatible.

10 lines (9 loc) 326 B
/** * Escape html special chars * @param {string} text - String to escape * @return {string} - Escaped html string */ export function escapeHTML( text ) { const map = { '&' : '&amp;', '<' : '&lt;', '>' : '&gt;', '"' : '&quot;', "'" : '&#039;' }; return text.replace( /[&<>"']/g, ( m ) => { return map[ m ]; } ); }