escape-html.js 197 B

1234567891011
  1. const map = {
  2. '&': '&',
  3. '<': '&lt;',
  4. '>': '&gt;',
  5. '"': '&quot;',
  6. "'": '&#039;'
  7. };
  8. export default function(text) {
  9. return text.replace(/[&<>"']/g, function(m) { return map[m]; });
  10. }