From 12ce56be6b400f3fb22ccbecfbbdff422f2c7c50 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 5 Nov 2024 09:36:00 +0200 Subject: [PATCH] fix default title on h1 not defined in gemtext --- src/app/browser/window/tab/item/page.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 2be8c4c7..6e969ec2 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -974,12 +974,18 @@ pub fn migrate(tx: &Transaction) -> Result<(), String> { /// /// * this feature may be improved and moved outside @TODO fn uri_to_title(uri: &Uri) -> GString { - match uri.path().split('/').last() { - Some(filename) => gformat!("{filename}"), - None => match uri.host() { + let title = GString::from(match uri.path().split('/').last() { + Some(filename) => filename, + None => "", + }); + + if title.is_empty() { + match uri.host() { Some(host) => gformat!("{host}"), None => gformat!("Untitled"), - }, + } + } else { + title } }