git » sdk » commit faec034

Don't show omemo-sid in xmpp links

author Stephen Paul Weber
2025-10-27 16:39:02 UTC
committer Stephen Paul Weber
2025-10-27 16:39:02 UTC
parent e972d8131d280edfae496951977135b82deb1c81

Don't show omemo-sid in xmpp links

Just looks ugly and the user can't tell much by it

borogove/Autolink.hx +5 -1

diff --git a/borogove/Autolink.hx b/borogove/Autolink.hx
index 2f7b985..fd776c5 100644
--- a/borogove/Autolink.hx
+++ b/borogove/Autolink.hx
@@ -24,6 +24,7 @@ package borogove;
 
 import borogove.Stanza;
 using Lambda;
+using StringTools;
 
 class Autolink {
 
@@ -356,8 +357,11 @@ class Autolink {
 			final pos = pattern.matchedPos();
 			final link = pattern.matched(0);
 			final uri = !addHttps || StringTools.contains(link, "://") ? link : "https://" + link;
+			var text = link.startsWith("xmpp:") ? ~/omemo-sid[^;]+;?/.replace(link, "") : link;
+			text = link.startsWith("xmpp:") && text.endsWith(";") ? text.substr(0, text.length - 1) : text;
+			text = text.endsWith("?") ? text.substr(0, text.length - 1) : text;
 
-			return { span: Element(new Stanza("a", { href: uri }).text(link)), start: pos.pos, end: pos.pos + pos.len };
+			return { span: Element(new Stanza("a", { href: uri }).text(text)), start: pos.pos, end: pos.pos + pos.len };
 		} else {
 			return { span: null, start: s.length, end: s.length };
 		}