diff --git a/js/views/chatview.js b/js/views/chatview.js
index 16788817422..df1cdcf265c 100644
--- a/js/views/chatview.js
+++ b/js/views/chatview.js
@@ -458,11 +458,12 @@
* copied from OCP.Comments and adjusted accordingly.
*/
// var urlRegex = /(\s|^)(https?:\/\/)?((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig;
- var urlRegex = /(\s|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig;
- return message.replace(urlRegex, function (_, leadingSpace, protocol, url, trailingSpace) {
+ var urlRegex = /(\s|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(?=\s|$)/ig;
+ return message.replace(urlRegex, function (_, leadingSpace, protocol, url) {
+ var trailingClosingBracket = '';
if (url.substr(-1) === ')' && url.indexOf('(') === -1) {
url = url.substr(0, url.length - 1);
- trailingSpace = ')' + trailingSpace;
+ trailingClosingBracket = ')';
}
var linkText = url;
// if (!protocol) {
@@ -472,7 +473,7 @@
linkText = protocol + url;
}
- return leadingSpace + '' + linkText + '' + trailingSpace;
+ return leadingSpace + '' + linkText + '' + trailingClosingBracket;
});
},