mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 12:03:11 +00:00
Better URI replace for messages. Close #16
This commit is contained in:
parent
d00e8803d3
commit
8bcb61bdbd
1 changed files with 12 additions and 3 deletions
|
@ -395,10 +395,19 @@ $(function() {
|
|||
|
||||
Handlebars.registerHelper(
|
||||
"uri", function(text) {
|
||||
text = escape(text);
|
||||
return URI.withinString(text, function(url) {
|
||||
return "<a href='" + url.replace(/^www/, "//www") + "' target='_blank'>" + url + "</a>";
|
||||
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 + "}",
|
||||
"<a href='" + urls[i].replace(/^www/, "//www") + "' target='_blank'>" + urls[i] + "</a>"
|
||||
);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue