All files / lib/utils escape-html.js

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 161x                   1x     130x    
const chars = {
  '&': '&',
  '<': '&lt;',
  '>': '&gt;',
  '"': '&quot;',
  "'": '&#39;',
  '\xA0': '&nbsp;',
  '×': '&times;',
};
 
const regex = new RegExp(`(${Object.keys(chars).join('|')})`, ['g']);
 
export default function escapeHTML(str) {
  return str.replace(regex, c => chars[c]);
}