Better URI replace for messages. Close #16

This commit is contained in:
Mattias Erming 2014-06-18 13:51:23 +02:00
parent d00e8803d3
commit 8bcb61bdbd

View File

@ -395,10 +395,19 @@ $(function() {
Handlebars.registerHelper( Handlebars.registerHelper(
"uri", function(text) { "uri", function(text) {
text = escape(text); var urls = [];
return URI.withinString(text, function(url) { text = URI.withinString(text, function(url) {
return "<a href='" + url.replace(/^www/, "//www") + "' target='_blank'>" + url + "</a>"; urls.push(url);
return "{" + (urls.length - 1) + "}";
}); });
text = escape(text);
for (var i in urls) {
text = text.replace(
"{" + i + "}",
"<a href='" + urls[i].replace(/^www/, "//www") + "' target='_blank'>" + urls[i] + "</a>"
);
}
return text;
} }
); );