diff --git a/src/app/browser/main/tab/page.cpp b/src/app/browser/main/tab/page.cpp index db7f2f25..a4a57eca 100644 --- a/src/app/browser/main/tab/page.cpp +++ b/src/app/browser/main/tab/page.cpp @@ -54,7 +54,6 @@ Page::~Page() void Page::update() { - // Route by request scheme if ("file" == navbar->get_request_scheme()) { // @TODO @@ -115,8 +114,36 @@ void Page::update() ); } + // Scheme not found but host provided, redirect to gemini:// + else if (!navbar->get_request_host().empty()) + { + std::string request = "gemini://"; + + request += navbar->get_request_host(); // @TODO validate + + if (!navbar->get_request_port().empty()) + { + request += std::stoi( + navbar->get_request_port() + ); + } + + request += navbar->get_request_path(); + + if (!navbar->get_request_query().empty()) + { + request += "?" + navbar->get_request_query(); + } + + navbar->set_request( + request + ); + + update(); + } + else { - // @TODO + // @TODO search request } } \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navbar.cpp b/src/app/browser/main/tab/page/navbar.cpp index 4910b18e..b8c95b0a 100644 --- a/src/app/browser/main/tab/page/navbar.cpp +++ b/src/app/browser/main/tab/page/navbar.cpp @@ -99,7 +99,18 @@ void Navbar::refresh() ); } -// Public getters +// Setters +void Navbar::set_request( + const std::string value +) { + request->set_text( + value + ); + + // refresh(); not wanted as on change listener do same @TODO +} + +// Getters Glib::ustring Navbar::get_request() { return request->get_text(); diff --git a/src/app/browser/main/tab/page/navbar.hpp b/src/app/browser/main/tab/page/navbar.hpp index f17b750d..9b026a90 100644 --- a/src/app/browser/main/tab/page/navbar.hpp +++ b/src/app/browser/main/tab/page/navbar.hpp @@ -42,6 +42,11 @@ namespace app::browser::main::tab::page // Actions void refresh(); + // Setters + void set_request( + const std::string value + ); + // Getters Glib::ustring get_request();