From: Cory Chaplin Date: Sun, 11 May 2014 00:04:41 +0000 (+0200) Subject: Smarter way to avoid triming the space before a channel name X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6547f1181f23057a86142c0ee2ae312d65278c72;p=KiwiIRC.git Smarter way to avoid triming the space before a channel name --- diff --git a/client/src/views/channel.js b/client/src/views/channel.js index 1ebc666..04639f3 100644 --- a/client/src/views/channel.js +++ b/client/src/views/channel.js @@ -59,7 +59,7 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({ time_difference, sb = this.model.get('scrollback'), prev_msg = sb[sb.length-2], - network, hour, pm, extra_space = ''; + network, hour, pm; // Nick highlight detecting if ((new RegExp('(^|\\W)(' + escapeRegex(_kiwi.app.connections.active_connection.get('nick')) + ')(\\W|$)', 'i')).test(msg.msg)) { @@ -72,12 +72,9 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({ // Make the channels clickable if ((network = this.model.get('network'))) { - re = new RegExp('(?:^|\\s)([' + escapeRegex(network.get('channel_prefix')) + '][^ ,\\007]+)', 'g'); - msg.msg = msg.msg.replace(re, function (match) { - if(match.match(/^\s+/g)) { - extra_space = ' '; - } - return extra_space + '' + _.escape(match.trim()) + ''; + re = new RegExp('(^|\\s)([' + escapeRegex(network.get('channel_prefix')) + '][^ ,\\007]+)', 'g'); + msg.msg = msg.msg.replace(re, function (m1, m2) { + return m2 + '' + _.escape(m1.trim()) + ''; }); }