hummingbird-me/hummingbird

View on GitHub
frontend/app/utils/escape-html.js

Summary

Maintainability
A
0 mins
Test Coverage
var entityMap = {
  "&": "&",
  "<": "&lt;",
  ">": "&gt;",
  '"': '&quot;',
  "'": '&#39;',
  "/": '&#x2F;'
};

export default function escapeHtml(string) {
  return String(string).replace(/[&<>"'\/]/g, function(s) {
    return entityMap[s];
  });
}