From d0b3f9014a7139356d9d566972dba249c750396c Mon Sep 17 00:00:00 2001 From: calzoneman Date: Mon, 13 May 2013 19:54:52 -0400 Subject: [PATCH] Make links unaffected by chat filters --- channel.js | 17 ++++++++++++----- www/assets/js/media.js | 1 - 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/channel.js b/channel.js index 2dcb6143..f4ed7aee 100644 --- a/channel.js +++ b/channel.js @@ -1269,14 +1269,21 @@ Channel.prototype.chainMessage = function(user, msg, data) { } Channel.prototype.filterMessage = function(msg) { - msg = msg.replace(/(((https?)|(ftp))(:\/\/[0-9a-zA-Z\.]+(:[0-9]+)?[^\s$]+))/g, "$1"); + const link = /((?:(?:https?)|(?:ftp))(?::\/\/[0-9a-zA-Z\.]+(?::[0-9]+)?[^\s$]+))/g; + var subs = msg.split(link); // Apply other filters - for(var i = 0; i < this.filters.length; i++) { - if(!this.filters[i].active) + for(var j = 0; j < subs.length; j++) { + if(subs[j].match(link)) { + subs[j] = subs[j].replace(link, "$1"); continue; - msg = this.filters[i].filter(msg); + } + for(var i = 0; i < this.filters.length; i++) { + if(!this.filters[i].active) + continue; + subs[j] = this.filters[i].filter(subs[j]); + } } - return msg; + return subs.join(""); } Channel.prototype.sendMessage = function(username, msg, msgclass, data) { diff --git a/www/assets/js/media.js b/www/assets/js/media.js index 0e378a6c..8e59a442 100644 --- a/www/assets/js/media.js +++ b/www/assets/js/media.js @@ -379,7 +379,6 @@ Media.prototype.update = function(data) { this.getTime(function(seconds) { var time = data.currentTime; var diff = time - seconds || time; - console.log(this); if(diff > USEROPTS.sync_accuracy) { this.seek(time);