From 8bcb61bdbdb30323beec180b9c0c759a10332d18 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Wed, 18 Jun 2014 13:51:23 +0200 Subject: [PATCH] Better URI replace for messages. Close #16 --- client/js/chat.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/js/chat.js b/client/js/chat.js index 1154ebcf..672a0411 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -395,10 +395,19 @@ $(function() { Handlebars.registerHelper( "uri", function(text) { - text = escape(text); - return URI.withinString(text, function(url) { - return "" + url + ""; + var urls = []; + text = URI.withinString(text, function(url) { + urls.push(url); + return "{" + (urls.length - 1) + "}"; }); + text = escape(text); + for (var i in urls) { + text = text.replace( + "{" + i + "}", + "" + urls[i] + "" + ); + } + return text; } );