urlplugin: fix regex

This commit is contained in:
Tristan Matthews 2013-10-01 21:20:49 -04:00 committed by David Cormier
parent ab490074d3
commit 5168b833cb

View file

@ -149,11 +149,10 @@ weechat.factory('youtubePlugin', [function() {
weechat.factory('urlPlugin', [function() { weechat.factory('urlPlugin', [function() {
var contentForMessage = function(message) { var contentForMessage = function(message) {
var prefix = 'http://'; var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/;
var linkIndex = message.indexOf(prefix); var url = message.match(urlPattern);
if (linkIndex != -1) { if (url) {
var token = message.substr(linkIndex); return '<a href="' + url[0] + '">' + message + '</a>';
return '<a href="' + token + '">' + token + '</a>';
} }
return null; return null;
} }