add solveMarkdownLinks to eventUtils

dev
adb 4 years ago
parent 01fe023d06
commit 1dea2f76ad

@ -8,12 +8,21 @@ export function solveTextLinks(text){
}
return `${space}<a href="${hyperlink}" target="_blank">${url}</a>`;
}
)
);
}
export function parseMessage(msg){
return solveTextLinks(
msg.replace(/>.*\n/gm, '').trim()
.replace(/</g, '&lt')
.replace(/>/g, '&gt')
export function solveMarkdownLinks(text){
return (text || '').replace(
/\[([\w\s\d/\\._+-]+)]\(((?:\/|https?:\/\/)[\w\d/.?=#_+-]+)\)/gi,
(match, text, url)=>{
return `<a href="${url}" target="_blank">${text}</a>`;
}
);
}
export function fixHtml(text){
return text.replace(/>.*\n/gm, '').trim()
.replace(/</g, '&lt')
.replace(/>/g, '&gt');
}
export function parseMessage(text){
return solveMarkdownLinks(solveTextLinks(fixHtml(text)));
}
Loading…
Cancel
Save