From 28d4ec779daeca1696fb8e512f65f51f5bec76f3 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 23 Feb 2017 09:37:35 -0800 Subject: [PATCH 1/6] Fix localhost links --- src/Linkifier.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Linkifier.ts b/src/Linkifier.ts index e0f5eb92..7a813733 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -12,8 +12,9 @@ const negatedDomainCharacterSet = '[^\\da-z\\.-]+'; const domainBodyClause = '(' + domainCharacterSet + ')'; const tldClause = '([a-z\\.]{2,6})'; const ipClause = '((\\d{1,3}\\.){3}\\d{1,3})'; +const localHostClause = '(localhost)'; const portClause = '(:\\d{1,5})'; -const hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + ')' + portClause + '?'; +const hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?'; const pathClause = '(\\/[\\/\\w\\.-]*)*'; const queryStringClause = '(\\?[\\w\\[\\]\\(\\)\\/\\?\\!#@$&\'*+,:;]*)?'; const negatedPathCharacterSet = '[^\\/\\w\\.-]+'; From b81068716366d061a693931c7c8a530c80735898 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 23 Feb 2017 09:42:59 -0800 Subject: [PATCH 2/6] Support linking = in query strings --- src/Linkifier.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Linkifier.ts b/src/Linkifier.ts index 7a813733..1381bf8b 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -16,7 +16,7 @@ const localHostClause = '(localhost)'; const portClause = '(:\\d{1,5})'; const hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?'; const pathClause = '(\\/[\\/\\w\\.-]*)*'; -const queryStringClause = '(\\?[\\w\\[\\]\\(\\)\\/\\?\\!#@$&\'*+,:;]*)?'; +const queryStringClause = '(\\?[\\w\\[\\]\\(\\)\\/\\?\\!#@$&\'*+,:;\\=]*)?'; const negatedPathCharacterSet = '[^\\/\\w\\.-]+'; const bodyClause = hostClause + pathClause + queryStringClause; const start = '(?:^|' + negatedDomainCharacterSet + ')('; From 9aae43961f38e0a6f68e448f71d4917f1d1f5416 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 23 Feb 2017 09:53:20 -0800 Subject: [PATCH 3/6] Support linking hash fragments --- src/Linkifier.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Linkifier.ts b/src/Linkifier.ts index 1381bf8b..4ec9018c 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -16,9 +16,11 @@ const localHostClause = '(localhost)'; const portClause = '(:\\d{1,5})'; const hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?'; const pathClause = '(\\/[\\/\\w\\.-]*)*'; -const queryStringClause = '(\\?[\\w\\[\\]\\(\\)\\/\\?\\!#@$&\'*+,:;\\=]*)?'; +const queryStringHashFragmentCharacterSet = '[\\w\\[\\]\\(\\)\\/\\?\\!#@$&\'*+,:;\\=]*'; +const queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?'; +const hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?'; const negatedPathCharacterSet = '[^\\/\\w\\.-]+'; -const bodyClause = hostClause + pathClause + queryStringClause; +const bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause; const start = '(?:^|' + negatedDomainCharacterSet + ')('; const end = ')($|' + negatedPathCharacterSet + ')'; const strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end); From cb80ce0d2c5edc473c7ca3c401d0c42c8f50c365 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 23 Feb 2017 09:55:05 -0800 Subject: [PATCH 4/6] Link . and - in hash fragments and query strings --- src/Linkifier.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Linkifier.ts b/src/Linkifier.ts index 4ec9018c..6ead8e09 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -16,7 +16,7 @@ const localHostClause = '(localhost)'; const portClause = '(:\\d{1,5})'; const hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?'; const pathClause = '(\\/[\\/\\w\\.-]*)*'; -const queryStringHashFragmentCharacterSet = '[\\w\\[\\]\\(\\)\\/\\?\\!#@$&\'*+,:;\\=]*'; +const queryStringHashFragmentCharacterSet = '[\\w\\[\\]\\(\\)\\/\\?\\!#@$&\'*+,:;\\=\\.\\-]*'; const queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?'; const hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?'; const negatedPathCharacterSet = '[^\\/\\w\\.-]+'; From ccadf3fccac5260eca83578387a282195e146383 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 23 Feb 2017 10:02:18 -0800 Subject: [PATCH 5/6] Support percent and numbers in query/hash fragments --- src/Linkifier.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Linkifier.ts b/src/Linkifier.ts index 6ead8e09..280ad42d 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -16,7 +16,7 @@ const localHostClause = '(localhost)'; const portClause = '(:\\d{1,5})'; const hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?'; const pathClause = '(\\/[\\/\\w\\.-]*)*'; -const queryStringHashFragmentCharacterSet = '[\\w\\[\\]\\(\\)\\/\\?\\!#@$&\'*+,:;\\=\\.\\-]*'; +const queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;\\=\\.\\-]*'; const queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?'; const hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?'; const negatedPathCharacterSet = '[^\\/\\w\\.-]+'; From 7279ee0f5ff3cb19116c8b897165a94ffacfb580 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 24 Feb 2017 08:56:11 -0800 Subject: [PATCH 6/6] Support % in URLs --- src/Linkifier.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Linkifier.ts b/src/Linkifier.ts index 280ad42d..e8d6371d 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -15,11 +15,11 @@ const ipClause = '((\\d{1,3}\\.){3}\\d{1,3})'; const localHostClause = '(localhost)'; const portClause = '(:\\d{1,5})'; const hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?'; -const pathClause = '(\\/[\\/\\w\\.-]*)*'; +const pathClause = '(\\/[\\/\\w\\.\\-%]*)*'; const queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;\\=\\.\\-]*'; const queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?'; const hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?'; -const negatedPathCharacterSet = '[^\\/\\w\\.-]+'; +const negatedPathCharacterSet = '[^\\/\\w\\.\\-%]+'; const bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause; const start = '(?:^|' + negatedDomainCharacterSet + ')('; const end = ')($|' + negatedPathCharacterSet + ')';