add missed trailing slash condition based on the current url

This commit is contained in:
yggverse 2025-06-26 20:53:15 +03:00
parent 6a3ee89d8b
commit 4d1fa804ba

View file

@ -51,6 +51,9 @@ impl Nex for TextView {
// Collect links
for line in data.lines() {
// * skip links processing when the current location does not contain trailing slash
// it may be confusing: gemini://bbs.geminispace.org/s/nex/29641
if base.to_string().ends_with("/") {
// just borrow ggemtext parser as compatible API
if let Some(link) = ggemtext::line::Link::parse(line) {
if let Some(uri) = link.uri(Some(base)) {
@ -79,7 +82,11 @@ impl Nex for TextView {
&[&a],
);
if let Some(alt) = link.alt {
buffer.insert_with_tags(&mut buffer.end_iter(), &format!(" {alt}"), &[&p]);
buffer.insert_with_tags(
&mut buffer.end_iter(),
&format!(" {alt}"),
&[&p],
);
}
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
@ -88,6 +95,7 @@ impl Nex for TextView {
continue;
}
}
}
// Nothing match custom tags above,
// just append plain text covered in empty tag (to handle controller events properly)
buffer.insert_with_tags(&mut buffer.end_iter(), line, &[&p]);