[addon linkify] Further optimize URL algorithm

This commit is contained in:
paris
2015-01-06 13:03:07 +02:00
parent 3e7ab290fa
commit e100ee0cc0
+6 -3
View File
@@ -21,13 +21,16 @@
*/
var exports = {},
protocolClause = '(https?:\\/\\/)',
domainBodyClause = '([\\da-z\\.-]+)',
domainCharacterSet = '[\\da-z\\.-]+',
negatedDomainCharacterSet = '[^\\da-z\\.-]+',
domainBodyClause = '(' + domainCharacterSet + ')',
tldClause = '([a-z\\.]{2,6})',
hostClause = domainBodyClause + '\\.' + tldClause,
pathClause = '([\\/\\w\\.-]*)*\\/?',
negatedPathCharacterSet = '[^\\/\\w\\.-]+',
bodyClause = hostClause + pathClause,
start = '(?:^|\\s+|\\(+|\\[+)(',
end = ')($|\\s+|\\)+|\\]+)',
start = '(?:^|' + negatedDomainCharacterSet + ')(',
end = ')($|' + negatedPathCharacterSet + ')',
urlClause = start + protocolClause + '?' + bodyClause + end,
urlRegex = new RegExp(urlClause);