From 0fb00d7ec1a8eb3aa0ed0099563e99d682dfe6b8 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Sat, 14 Jun 2025 15:18:06 -0400 Subject: [PATCH] improve `regexLink` to reduce false positives --- lib/constants.dart | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/constants.dart b/lib/constants.dart index 8537b022..f9c18f49 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -19,9 +19,22 @@ const zeroWidthEmotes = [ /// Regex for matching strings that contain lower or upper case English characters. final regexEnglish = RegExp(r'[a-zA-Z]'); +/// Regex for matching URLs and file names in text. final regexLink = RegExp( - r'(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)', - caseSensitive: false, // Make it case-insensitive + r'(?