From 23cfa3d8240291d3d854392f0c50db7877818d63 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 7 Jun 2016 22:12:38 -0700 Subject: [PATCH] Add IP addresses to linkify Fixes #91 --- addons/linkify/linkify.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/linkify/linkify.js b/addons/linkify/linkify.js index 152404d4..8b222564 100644 --- a/addons/linkify/linkify.js +++ b/addons/linkify/linkify.js @@ -30,8 +30,10 @@ negatedDomainCharacterSet = '[^\\da-z\\.-]+', domainBodyClause = '(' + domainCharacterSet + ')', tldClause = '([a-z\\.]{2,6})', - hostClause = domainBodyClause + '\\.' + tldClause, - pathClause = '([\\/\\w\\.-]*)*\\/?', + ipClause = '((\\d{1,3}\\.){3}\\d{1,3})', + portClause = '(:\\d{1,5})', + hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|(' + ipClause + portClause + '?))', + pathClause = '(\\/[\\/\\w\\.-]*)*', negatedPathCharacterSet = '[^\\/\\w\\.-]+', bodyClause = hostClause + pathClause, start = '(?:^|' + negatedDomainCharacterSet + ')(', @@ -41,7 +43,6 @@ lenientUrlRegex = new RegExp(lenientUrlClause), strictUrlRegex = new RegExp(strictUrlClause); - /** * Converts all valid URLs found in the given terminal line into * hyperlinks. The terminal line can be either the HTML element itself