From b095a48ace2e89a91bc4fe4af5cafd4a4969c69e Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 21 Aug 2022 21:37:00 +0200 Subject: [PATCH] Fix the logic of get_url_site(). Also small binding cleanups. --- modules/web/http/web_server_request.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/web/http/web_server_request.cpp b/modules/web/http/web_server_request.cpp index c00ddbcf8..2bfa12a71 100644 --- a/modules/web/http/web_server_request.cpp +++ b/modules/web/http/web_server_request.cpp @@ -410,7 +410,9 @@ String WebServerRequest::get_url_root_current() const { String WebServerRequest::get_url_site() const { String path = get_host(); - for (int i = _path_stack_pointer; i < _path_stack.size(); ++i) { + int s = MIN(_path_stack_pointer + 1, _path_stack.size()); + + for (int i = 0; i < s; ++i) { path += _path_stack[i]; path += "/"; } @@ -535,8 +537,8 @@ void WebServerRequest::_bind_methods() { ClassDB::bind_method(D_METHOD("get_file_file_name", "index"), &WebServerRequest::get_file_file_name); ClassDB::bind_method(D_METHOD("get_file_key", "index"), &WebServerRequest::get_file_key); ClassDB::bind_method(D_METHOD("get_file_length", "index"), &WebServerRequest::get_file_length); - ClassDB::bind_method(D_METHOD("get_file_data"), &WebServerRequest::get_file_data); - ClassDB::bind_method(D_METHOD("get_file_data_str"), &WebServerRequest::get_file_data_str); + ClassDB::bind_method(D_METHOD("get_file_data", "index"), &WebServerRequest::get_file_data); + ClassDB::bind_method(D_METHOD("get_file_data_str", "index"), &WebServerRequest::get_file_data_str); ClassDB::bind_method(D_METHOD("get_parameter", "key"), &WebServerRequest::get_parameter);