Browse Source

redirect to gemini:// on scheme not provided

CPP-GTK4
yggverse 4 months ago
parent
commit
a064778d68
  1. 31
      src/app/browser/main/tab/page.cpp
  2. 13
      src/app/browser/main/tab/page/navbar.cpp
  3. 5
      src/app/browser/main/tab/page/navbar.hpp

31
src/app/browser/main/tab/page.cpp

@ -54,7 +54,6 @@ Page::~Page() @@ -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() @@ -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
}
}

13
src/app/browser/main/tab/page/navbar.cpp

@ -99,7 +99,18 @@ void Navbar::refresh() @@ -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();

5
src/app/browser/main/tab/page/navbar.hpp

@ -42,6 +42,11 @@ namespace app::browser::main::tab::page @@ -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();

Loading…
Cancel
Save