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