From 7890add93c7c20938ae11eed8f24515778e9ea6d Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Sun, 23 Nov 2025 13:43:25 -0500 Subject: [PATCH] better link support --- lib/widgets/chat_page/room_chat.dart | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/widgets/chat_page/room_chat.dart b/lib/widgets/chat_page/room_chat.dart index 2f23655..cf4338a 100644 --- a/lib/widgets/chat_page/room_chat.dart +++ b/lib/widgets/chat_page/room_chat.dart @@ -112,7 +112,8 @@ class RoomChat extends HookConsumerWidget { builders: Builders( chatAnimatedListBuilder: (_, itemBuilder) => ChatAnimatedList( - itemBuilder: itemBuilder, + itemBuilder: + itemBuilder, // TODO: Load earlier onEndReached: notifier.loadOlder, onStartReached: () => notifier.markRead(), ), @@ -130,7 +131,24 @@ class RoomChat extends HookConsumerWidget { MessageGroupStatus? groupStatus, }) => FlyerChatTextMessage( customWidget: HtmlWidget( - message.metadata?["formatted"], + message.metadata?["formatted"].replaceAllMapped( + RegExp(regexLink, unicode: true), + (match) { + final full = match.group(0)!; + + // If no protocol is present, add https:// + final hasProtocol = + full.startsWith("http://") || + full.startsWith("https://") || + full.startsWith("ftp://"); + + final url = hasProtocol + ? full + : "https://$full"; + + return "$full"; + }, + ), customWidgetBuilder: (element) { if (element.localName == "mx-reply") { return SizedBox.shrink();