redirect to gemini:// on scheme not provided

This commit is contained in:
yggverse 2024-08-17 10:27:17 +03:00
parent 09542c5134
commit a064778d68
3 changed files with 46 additions and 3 deletions

View File

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

View File

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

View File

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