diff --git a/www/plan/plan.js b/www/plan/plan.js
index 7619bf9..186a661 100644
--- a/www/plan/plan.js
+++ b/www/plan/plan.js
@@ -204,6 +204,8 @@ class Store {
amount = amount || 1;
checked = Number(checked) || 0;
+ text = insertLinks(text);
+
try {
price = Number(price);
this.itemsObj[itemID] = { text: text, price: price, itemID: itemID, amount: amount, checked: checked };
@@ -624,4 +626,34 @@ function handleAjaxErrors(jqxhr, textStatus, error){
else {
alert("An error occured:\n"+error);
}
+}
+
+function insertLinks(text){
+ let markdownLink = /\[([a-zA-ZæøåÆØÅ0-9 &+-]+)\]\(((?:|http(?:|s):\/\/)[a-zA-Z0-9\/.\-+?=&]+)\)/gm;
+ let m;
+
+ while((m = markdownLink.exec(text)) !== null){
+ // This is necessary to avoid infinite loops with zero-width matches
+ if(m.index === markdownLink.lastIndex){
+ markdownLink.lastIndex++;
+ }
+
+ text = text.replace(m[0], ""+m[1]+"");
+ }
+
+ let linkRegex = /(?:([("']|)((?:[A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)(?:(?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/gm;
+ let n;
+ let inputText = text;
+ while((n = linkRegex.exec(inputText)) !== null){
+ // This is necessary to avoid infinite loops with zero-width matches
+ if(n.index === linkRegex.lastIndex){
+ linkRegex.lastIndex++;
+ }
+
+ if(n[1] === ""){
+ text = text.replace(n[0], ""+(n[2].replace('https://','').replace('http://', ''))+(n[2].length");
+ }
+ }
+
+ return text;
}
\ No newline at end of file