smartslack
Version:
SmartSlack is a node.js module for Slack's Real Time Messaging API
20 lines (19 loc) • 468 B
JavaScript
;
var _ = require('lodash');
/**
* Escape message text for Slack
* @param {string} text The slack message text
* @returns {string} text The escaped message text
*/
function slackEscape(text) {
if (_.isString(text)) {
var char = [['&', '&'], ['<', '<'], ['>', '>']];
_.each(char, function (i) {
text = text.replace(i[0], i[1]);
});
}
return text;
}
module.exports = {
escape: slackEscape
};