From 225bfef3e68ffa08a28e9a4613e31779bfefac21 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 4 May 2024 15:57:06 +0200 Subject: [PATCH] Tweak WebNode::get_full_uri() to give back the output what you'd normally assume when the uri segment is "/" under a WebRoot. --- modules/web/http/web_node.cpp | 9 +++++++++ .../browsable_folder_serve_web_page.cpp | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/web/http/web_node.cpp b/modules/web/http/web_node.cpp index ecdc11102..acb65bd3a 100644 --- a/modules/web/http/web_node.cpp +++ b/modules/web/http/web_node.cpp @@ -58,6 +58,15 @@ void WebNode::set_uri_segment(const String &val) { } String WebNode::get_full_uri(const bool slash_at_the_end) { + // Special case for WebRoots for ease of use + if (_uri_segment == "/") { + if (slash_at_the_end) { + return _uri_segment; + } else { + return String(); + } + } + if (slash_at_the_end) { return get_full_uri_parent(true) + _uri_segment + "/"; } else { diff --git a/modules/web/nodes/folder_serve_nodes/browsable_folder_serve_web_page.cpp b/modules/web/nodes/folder_serve_nodes/browsable_folder_serve_web_page.cpp index 5b0d0784e..ee464a26d 100644 --- a/modules/web/nodes/folder_serve_nodes/browsable_folder_serve_web_page.cpp +++ b/modules/web/nodes/folder_serve_nodes/browsable_folder_serve_web_page.cpp @@ -140,10 +140,6 @@ void BrowsableFolderServeWebPage::render_dir_page(const String &dir_uri, const V String uri = get_full_uri(false); - if (uri == "/") { - uri = ""; - } - b.div("file_list"); { if (!top_level) {