Jump To …

test.js

./
  • param string to be escaped
  • return escaped html
  • api undefined

Escape the given html.

Examples

utils.escape('<script></script>')
// => '&lt;script&gt;&lt;/script&gt;'
exports.escape = function(html){
  return String(html)
    .replace(/&(?!\w+;)/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;');
};