diff --git a/js/misc/util.js b/js/misc/util.js index 3ba2b7d79..ee3c27f56 100644 --- a/js/misc/util.js +++ b/js/misc/util.js @@ -9,10 +9,12 @@ const Main = imports.ui.main; // http://daringfireball.net/2010/07/improved_regex_for_matching_urls const _balancedParens = '\\((?:[^\\s()<>]+|(?:\\(?:[^\\s()<>]+\\)))*\\)'; +const _leadingJunk = '[\\s`(\\[{\'\\"<\u00AB\u201C\u2018]'; const _notTrailingJunk = '[^\\s`!()\\[\\]{};:\'\\".,<>?\u00AB\u00BB\u201C\u201D\u2018\u2019]'; const _urlRegexp = new RegExp( - '\\b(' + + '(^|' + _leadingJunk + ')' + + '(' + '(?:' + '[a-z][\\w-]+://' + // scheme:// '|' + @@ -43,7 +45,7 @@ const _urlRegexp = new RegExp( function findUrls(str) { let res = [], match; while ((match = _urlRegexp.exec(str))) - res.push({ url: match[0], pos: match.index }); + res.push({ url: match[2], pos: match.index + match[1].length }); return res; }