fix content type detection (make links clickable on uri contains trailing slash only)

This commit is contained in:
yggverse 2025-07-01 21:12:13 +03:00
parent 03732213ce
commit 8b7d4b1624

View File

@ -270,7 +270,7 @@ fn render(
} }
Err(e) => failure(&p, &e.to_string()), Err(e) => failure(&p, &e.to_string()),
}) })
} else if is_text(&q) { } else if is_document(&q) {
p.window_action.find.simple_action.set_enabled(true); p.window_action.find.simple_action.set_enabled(true);
match *f { match *f {
Feature::Default | Feature::Source => { Feature::Default | Feature::Source => {
@ -279,12 +279,12 @@ fn render(
Ok(d) => { Ok(d) => {
let t = if matches!(*f, Feature::Source) { let t = if matches!(*f, Feature::Source) {
p.content.to_text_source(d) p.content.to_text_source(d)
} else if q.ends_with("/") {
p.content.to_text_nex(&u, d)
} else if q.ends_with(".gmi") || q.ends_with(".gemini") { } else if q.ends_with(".gmi") || q.ends_with(".gemini") {
p.content.to_text_gemini(&u, d) p.content.to_text_gemini(&u, d)
} else if q.ends_with(".log") {
p.content.to_text_plain(d)
} else { } else {
p.content.to_text_nex(&u, d) p.content.to_text_plain(d)
}; };
event(&p, "Parsed".to_string(), Some(s)); event(&p, "Parsed".to_string(), Some(s));
p.search.set(Some(t.text_view)); p.search.set(Some(t.text_view));
@ -392,7 +392,7 @@ fn is_image(q: &str) -> bool {
|| q.ends_with(".webp") || q.ends_with(".webp")
} }
fn is_text(q: &str) -> bool { fn is_document(q: &str) -> bool {
q.ends_with(".txt") q.ends_with(".txt")
|| q.ends_with(".log") || q.ends_with(".log")
|| q.ends_with(".gmi") || q.ends_with(".gmi")
@ -402,5 +402,5 @@ fn is_text(q: &str) -> bool {
} }
fn is_renderable(q: &str) -> bool { fn is_renderable(q: &str) -> bool {
is_text(q) || is_image(q) is_document(q) || is_image(q)
} }