escapeHtml.js
410 Bytes
var toString = require('../lang/toString');
/**
* Escapes a string for insertion into HTML.
*/
function escapeHtml(str){
str = toString(str)
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/'/g, ''')
.replace(/"/g, '"');
return str;
}
module.exports = escapeHtml;