[backend/federation] Add support for hubzilla's hashtag formatting

A bit strange but here we are
This commit is contained in:
Laura Hausmann 2024-08-14 01:37:25 +02:00
parent 14720808db
commit c3eacb34c2
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -157,7 +157,8 @@ public class NoteService(
// @formatter:off // @formatter:off
var match = asNote.Tags?.OfType<ASHashtag>().Where(p => p.Name != null && p.Href != null) ?? []; var match = asNote.Tags?.OfType<ASHashtag>().Where(p => p.Name != null && p.Href != null) ?? [];
//TODO: refactor this to use the nodes object instead of matching on text //TODO: refactor this to use the nodes object instead of matching on text
text = match.Aggregate(text, (current, tag) => current.Replace($"[#{tag.Name!.TrimStart('#')}]({tag.Href})", $"#{tag.Name!.TrimStart('#')}")); text = match.Aggregate(text, (current, tag) => current.Replace($"[#{tag.Name!.TrimStart('#')}]({tag.Href})", $"#{tag.Name!.TrimStart('#')}")
.Replace($"#[{tag.Name!.TrimStart('#')}]({tag.Href})", $"#{tag.Name!.TrimStart('#')}"));
// @formatter:on // @formatter:on
} }