git-101 / src /js /util /escapeString.js
mervenoyan's picture
initial commit
45a32e2
var mapping = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'/': '&#x2F;'
};
module.exports = function(string) {
return ('' + string).replace(/[&<>"'\/]/g, function(match) {
return mapping[match];
});
};