Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬
Ruby actioncablechat-widgetconversationcustomer-supportdashboarddesigndockerdocker-imageherokuintercomjavascriptlivechatopensourcerailsrubysassvuejswhatsappzendesk
export const escapeHtml = (unsafe = '') => {
return unsafe
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
};
export const afterSanitizeAttributes = currentNode => {
if ('target' in currentNode) {
currentNode.setAttribute('target', '_blank');
}
};
// Mirrors DOMPurify's URI allowlist while adding the internal tool protocol.
const DOMPURIFY_SAFE_URI_PATTERN =
'(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|' +
'[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))';
const TOOL_LINK_URI_PATTERN = new RegExp(
`^(?:tool://|${DOMPURIFY_SAFE_URI_PATTERN})`,
'i'
);
export const domPurifyConfig = {
namedConfigurations: {
toolLinks: {
ALLOWED_URI_REGEXP: TOOL_LINK_URI_PATTERN,
},
},
hooks: {
afterSanitizeAttributes,
},
};