Merge pull request #230 from lorenzhs/fixirclinky

Don't irc linky #foo after forward / backward slashes
This commit is contained in:
David Cormier 2014-03-10 14:23:47 -04:00
commit 24a7fe2d42

View file

@ -28,7 +28,7 @@ weechat.filter('irclinky', ['$filter', function($filter) {
// However, it matches all *common* IRC channels while trying to minimise false positives. "#1" is much // However, it matches all *common* IRC channels while trying to minimise false positives. "#1" is much
// more likely to be "number 1" than "IRC channel #1". // more likely to be "number 1" than "IRC channel #1".
// Thus, we only match channels beginning with a # and having at least one letter in them. // Thus, we only match channels beginning with a # and having at least one letter in them.
var channelRegex = /(^|[\s,.:;?!"'()/\\])(#+[a-z0-9-_]*[a-z][a-z0-9-_]*)/gmi; var channelRegex = /(^|[\s,.:;?!"'()])(#+[a-z0-9-_]*[a-z][a-z0-9-_]*)/gmi;
// This is SUPER nasty, but ng-click does not work inside a filter, as the markup has to be $compiled first, which is not possible in filter afaik. // This is SUPER nasty, but ng-click does not work inside a filter, as the markup has to be $compiled first, which is not possible in filter afaik.
// Therefore, get the scope, fire the method, and $apply. Yuck. I sincerely hope someone finds a better way of doing this. // Therefore, get the scope, fire the method, and $apply. Yuck. I sincerely hope someone finds a better way of doing this.
linkiedText = linkiedText.replace(channelRegex, '$1<a href="#" onclick="var $scope = angular.element(event.target).scope(); $scope.openBuffer(\'$2\'); $scope.$apply();">$2</a>'); linkiedText = linkiedText.replace(channelRegex, '$1<a href="#" onclick="var $scope = angular.element(event.target).scope(); $scope.openBuffer(\'$2\'); $scope.$apply();">$2</a>');