Try avoiding trailing punctuation inside linkified URLs. (#4214)

Create `LinkfierHelper` and post-process URLSpans added to make sure they honor the actual URLs in text by removing unnecessarily added trailing punctuation.
This commit is contained in:
Jorge Martin Espinosa 2025-02-21 17:58:59 +01:00 committed by GitHub
parent b35feb0409
commit 5d8403b310
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 274 additions and 32 deletions

View file

@ -147,6 +147,7 @@ fun AnnotatedString.linkify(linkStyle: SpanStyle): AnnotatedString {
if (original.getLinkAnnotations(start, end).isEmpty() && original.getStringAnnotations("URL", start, end).isEmpty()) {
// Prevent linkifying domains in user or room handles (@user:domain.com, #room:domain.com)
if (start > 0 && !spannable[start - 1].isWhitespace()) continue
addStyle(
start = start,
end = end,