fix some browser bug

This commit is contained in:
Face
2025-09-08 20:19:50 +03:00
parent 3b87ab39c9
commit ac261e7d18
6 changed files with 30 additions and 17 deletions

View File

@@ -342,12 +342,7 @@ async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
.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<GurtResponse> {
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<GurtResponse> {
.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) => {

View File

@@ -27,21 +27,16 @@ pub(crate) async fn index(ctx: &ServerContext, _app_state: AppState) -> Result<G
let hostname = host_header.split(':').next().unwrap_or(host_header);
log::info!("Index handler - Host header: '{}', hostname: '{}'", host_header, hostname);
let current_dir = std::env::current_dir()
.map_err(|_| GurtError::invalid_message("Failed to get current directory"))?;
let (frontend_dir, file_name) = if hostname == "search.web" {
log::info!("Index handler serving search.html for search.web domain");
(current_dir.join("search-engine").join("frontend"), "search.html")
} else {
log::info!("Index handler serving index.html for domain: '{}'", hostname);
(current_dir.join("frontend"), "index.html")
};
let index_path = frontend_dir.join(file_name);
log::info!("Index handler attempting to read: '{}'", index_path.display());
match tokio::fs::read_to_string(&index_path).await {
Ok(content) => {

View File

@@ -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()

View File

@@ -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)

View File

@@ -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("/")

View File

@@ -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: