From ac261e7d18d395576af0dc9f3f84e15e922c807a Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Mon, 8 Sep 2025 20:19:50 +0300 Subject: [PATCH] fix some browser bug --- dns/src/gurt_server.rs | 10 ---------- dns/src/gurt_server/routes.rs | 5 ----- flumi/Scripts/Browser/DevTools.gd | 16 ++++++++++++++++ flumi/Scripts/Browser/DevToolsConsole.gd | 3 ++- flumi/Scripts/Utils/URLUtils.gd | 6 ++++++ flumi/Scripts/main.gd | 7 ++++++- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/dns/src/gurt_server.rs b/dns/src/gurt_server.rs index ce71db1..44ac1be 100644 --- a/dns/src/gurt_server.rs +++ b/dns/src/gurt_server.rs @@ -342,12 +342,7 @@ async fn serve_static_file(ctx: &ServerContext) -> Result { .map(|s| s.as_str()) .unwrap_or(""); - // Debug logging - log::info!("Static file request - Path: '{}', Host header: '{}'", path, host_header); - - // Extract hostname without port let hostname = host_header.split(':').next().unwrap_or(host_header); - log::info!("Extracted hostname: '{}'", hostname); // Strip query parameters from the path for static file serving let path_without_query = if let Some(query_pos) = path.find('?') { @@ -358,10 +353,8 @@ async fn serve_static_file(ctx: &ServerContext) -> Result { let file_path = if path_without_query == "/" || path_without_query == "" { if hostname == "search.web" { - log::info!("Serving search.html for search.web domain"); "search.html" } else { - log::info!("Serving index.html for domain: '{}'", hostname); "index.html" } } else { @@ -382,15 +375,12 @@ async fn serve_static_file(ctx: &ServerContext) -> Result { .map_err(|_| GurtError::invalid_message("Failed to get current directory"))?; let frontend_dir = if hostname == "search.web" { - log::info!("Using search-engine frontend directory"); current_dir.join("search-engine").join("frontend") } else { - log::info!("Using default frontend directory"); current_dir.join("frontend") }; let full_path = frontend_dir.join(file_path); - log::info!("Attempting to serve file: '{}' from directory: '{}'", full_path.display(), frontend_dir.display()); match tokio::fs::read_to_string(&full_path).await { Ok(content) => { diff --git a/dns/src/gurt_server/routes.rs b/dns/src/gurt_server/routes.rs index ce41ddc..c7757f1 100644 --- a/dns/src/gurt_server/routes.rs +++ b/dns/src/gurt_server/routes.rs @@ -27,21 +27,16 @@ pub(crate) async fn index(ctx: &ServerContext, _app_state: AppState) -> Result { diff --git a/flumi/Scripts/Browser/DevTools.gd b/flumi/Scripts/Browser/DevTools.gd index 191d408..37beedd 100644 --- a/flumi/Scripts/Browser/DevTools.gd +++ b/flumi/Scripts/Browser/DevTools.gd @@ -1,4 +1,20 @@ extends Control +@onready var console: DevToolsConsole = $DevTools/TabContainer/Console + +func _ready(): + connect_console_signals() + +func connect_console_signals(): + if console: + Trace.get_instance().log_message.connect(_on_trace_log_message) + +func get_console() -> DevToolsConsole: + return console + +func _on_trace_log_message(message: String, level: String, timestamp: float): + if console: + console.add_log_entry(message, level, timestamp) + func _on_close_button_pressed(): Engine.get_main_loop().current_scene._toggle_dev_tools() diff --git a/flumi/Scripts/Browser/DevToolsConsole.gd b/flumi/Scripts/Browser/DevToolsConsole.gd index 1effed0..e6a3658 100644 --- a/flumi/Scripts/Browser/DevToolsConsole.gd +++ b/flumi/Scripts/Browser/DevToolsConsole.gd @@ -86,7 +86,8 @@ func create_log_item(entry: Dictionary) -> Control: "scroll_fit_content_height": true, "transparent_background": true, "syntax_highlighter": input_line.syntax_highlighter.duplicate(), - "block_editing_signals": true + "block_editing_signals": true, + "size_flags_vertical": Control.SIZE_SHRINK_CENTER }) message_code_edit.gui_input.connect(_on_log_code_edit_gui_input) diff --git a/flumi/Scripts/Utils/URLUtils.gd b/flumi/Scripts/Utils/URLUtils.gd index 6961dec..7a22a53 100644 --- a/flumi/Scripts/Utils/URLUtils.gd +++ b/flumi/Scripts/Utils/URLUtils.gd @@ -48,6 +48,12 @@ static func resolve_url(base_url: String, relative_url: String) -> String: else: host = remainder.substr(0, first_slash) var path = remainder.substr(first_slash + 1) + + # Remove query parameters from the path for URL resolution + var query_start = path.find("?") + if query_start != -1: + path = path.substr(0, query_start) + if not path.is_empty(): current_path_parts = path.split("/") diff --git a/flumi/Scripts/main.gd b/flumi/Scripts/main.gd index 7fbc65f..e8242c0 100644 --- a/flumi/Scripts/main.gd +++ b/flumi/Scripts/main.gd @@ -485,7 +485,12 @@ func render_content(html_bytes: PackedByteArray) -> void: if scripts.size() > 0 and lua_api: parser.process_scripts(lua_api, null) if parse_result.external_scripts and not parse_result.external_scripts.is_empty(): - await parser.process_external_scripts(lua_api, null, current_domain) + # Extract base URL without query parameters for script resolution + var base_url_for_scripts = current_domain + var query_pos = base_url_for_scripts.find("?") + if query_pos != -1: + base_url_for_scripts = base_url_for_scripts.substr(0, query_pos) + await parser.process_external_scripts(lua_api, null, base_url_for_scripts) var postprocess_element = parser.process_postprocess() if postprocess_element: