From 7820c0fb5cbfb5d41fa484aa5f9d0481318cfbeb Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Tue, 16 Feb 2021 17:01:08 +1100 Subject: BrowserTab: use cleaner titles for pages without them For sites that do not have a page title (i.e no '#' heading) the document's filename is used. If no filename exists, then the hostname of the page is used. --- src/browsertab.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 1bcc20c..92f3b7d 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -793,7 +793,16 @@ void BrowserTab::updatePageTitle() { if (page_title.isEmpty()) { - page_title = this->current_location.toString(); + // Use document filename as title instead. + page_title = this->current_location.path(); + auto parts = page_title.split("/"); + page_title = parts[parts.length() - 1]; + + if (page_title.isEmpty()) + { + // Just use the hostname if we can't find anything else + page_title = this->current_location.host(); + } } // TODO: Shorten lengthy titles? -- cgit v1.2.3