term-notify-server/notifysrv/utils/string.js

14 lines
279 B
JavaScript

module.exports = {
encodeHtml: function ( str, br )
{
str = ( str + "" ).replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;")
;
if( br ) str = str.replace( /\n/g, "<br/>" );
return str;
}
}