diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js
index 38bd5e8..bae8065 100644
--- a/webapp/titanembeds/static/js/embed.js
+++ b/webapp/titanembeds/static/js/embed.js
@@ -743,6 +743,13 @@
}
function parse_message_markdown(text) {
+ var geturl_regex = /(\(.*?)?\b((?:https?|ftp|file):\/\/[-a-z0-9+&@#\/%?=~_()|!:,.;]*[-a-z0-9+&@#\/%=~_()|])/ig;
+ var links = text.match(geturl_regex); // temporarily remove urls so markdown won't mark inside of the url
+ if (links) {
+ for (var i = 0; i < links.length; i++) {
+ text = text.replace(links[i], "$LINK"+i+"$");
+ }
+ }
text = text.replace(/\*\*(.*?)\*\*/g, "$1");
text = text.replace(/\*(.*?)\*/g, "$1");
text = text.replace(/__(.*?)__/g, "$1");
@@ -750,6 +757,11 @@
text = text.replace(/~~(.*?)~~/g, "$1");
text = text.replace(/\`\`\`([^]+)\`\`\`/g, "$1
");
text = text.replace(/\`(.*?)\`/g, "$1
");
+ if (links) {
+ for (var i = 0; i < links.length; i++) {
+ text = text.replace("$LINK"+i+"$", links[i]);
+ }
+ }
return text;
}