From 5168b833cb0fea1c189a47210d413cbe112b31a1 Mon Sep 17 00:00:00 2001 From: Tristan Matthews Date: Tue, 1 Oct 2013 21:20:49 -0400 Subject: [PATCH] urlplugin: fix regex --- js/websockets.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/websockets.js b/js/websockets.js index 91e4ba4..40d1381 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -149,11 +149,10 @@ weechat.factory('youtubePlugin', [function() { weechat.factory('urlPlugin', [function() { var contentForMessage = function(message) { - var prefix = 'http://'; - var linkIndex = message.indexOf(prefix); - if (linkIndex != -1) { - var token = message.substr(linkIndex); - return '' + token + ''; + var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/; + var url = message.match(urlPattern); + if (url) { + return '' + message + ''; } return null; }