From 0840c3f8f7ea491ec9c7f4ff11a7becf21435dd0 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 23 Nov 2022 13:15:38 -0600 Subject: Fix: dont detect double dots as urls --- src/lib/strings.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/strings.ts') diff --git a/src/lib/strings.ts b/src/lib/strings.ts index 6457e4b90..f884cc86c 100644 --- a/src/lib/strings.ts +++ b/src/lib/strings.ts @@ -83,7 +83,7 @@ export function extractEntities( { // links const re = - /(^|\s)((https?:\/\/[\S]+)|([a-z][a-z0-9]*\.[a-z0-9\.]+[\S]*))(\b)/dg + /(^|\s)((https?:\/\/[\S]+)|([a-z][a-z0-9]*(\.[a-z0-9]+)+[\S]*))(\b)/dg while ((match = re.exec(text))) { let value = match[2] if (!value.startsWith('http')) { @@ -108,7 +108,7 @@ interface DetectedLink { type DetectedLinkable = string | DetectedLink export function detectLinkables(text: string): DetectedLinkable[] { const re = - /((^|\s)@[a-z0-9\.-]*)|((^|\s)https?:\/\/[\S]+)|((^|\s)[a-z][a-z0-9]*\.[a-z0-9\.]+[\S]*)/gi + /((^|\s)@[a-z0-9\.-]*)|((^|\s)https?:\/\/[\S]+)|((^|\s)[a-z][a-z0-9]*(\.[a-z0-9]+)+[\S]*)/gi const segments = [] let match let start = 0 -- cgit 1.4.1