urlplugin: fix regex
This commit is contained in:
parent
ab490074d3
commit
5168b833cb
1 changed files with 4 additions and 5 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue