improve link regex

This commit is contained in:
Tommy Chow 2025-03-23 21:53:47 -07:00
parent b6a7c94293
commit c7c85af6b4
2 changed files with 6 additions and 1 deletions

View file

@ -19,6 +19,11 @@ const zeroWidthEmotes = [
/// Regex for matching strings that contain lower or upper case English characters.
final regexEnglish = RegExp(r'[a-zA-Z]');
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
);
/// The default badge width and height.
const defaultBadgeSize = 18.0;

View file

@ -694,7 +694,7 @@ class IRCMessage {
}
},
);
} else if (RegExp(r'https?:\/\/').hasMatch(text)) {
} else if (regexLink.hasMatch(text)) {
return TextSpan(
text: text,
style: style?.copyWith(