From e6a7d19948485054f2fa74fabeadff1de0667bb3 Mon Sep 17 00:00:00 2001 From: Stefan Koelle Date: Thu, 17 Sep 2026 19:53:28 +0200 Subject: [PATCH] feat: auto-link URLs in chat messages --- src/api/templates/contact.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/api/templates/contact.html b/src/api/templates/contact.html index d0c1a00..5105096 100644 --- a/src/api/templates/contact.html +++ b/src/api/templates/contact.html @@ -367,6 +367,15 @@ word-break: break-word; } + .chat-msg-bubble a { + color: inherit; + text-decoration: underline; + } + + .chat-msg.own .chat-msg-bubble a { + color: #fff; + } + .chat-msg.own .chat-msg-bubble { background: #0066cc; color: #fff; @@ -678,6 +687,10 @@ const ownNorm = norm(ownName); + function linkify(text) { + return text.replace(/(https?:\/\/[^\s<]+)/g, '$1'); + } + function renderMsg(m) { const isOwn = norm(m.sender_name) === ownNorm; const div = document.createElement("div"); @@ -687,7 +700,7 @@ if (!isOwn && total !== null && total > batchSize) { html += '
' + escHtml(m.sender_name) + '
'; } - const text = m.content ? escHtml(m.content) : '[' + m.message_type + ']'; + const text = m.content ? linkify(escHtml(m.content)) : '[' + m.message_type + ']'; html += '
' + text + '
'; if (m.reactions && m.reactions.length > 0) { html += '
';