Skip to content

Commit 2a89d5e

Browse files
committed
web_page: fix urls without scheme
1 parent a971024 commit 2a89d5e

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ _build/
2020
_build32/
2121
_build64/
2222
*.inc
23+
.cache/
2324

2425
# Test results
2526
*-FAILED.png

support/gtkmm4/html_widget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ void html_widget::snapshot_vfunc(const Glib::RefPtr<Gtk::Snapshot>& snapshot)
131131

132132
void html_widget::get_client_rect(litehtml::position& client) const
133133
{
134-
client.x = m_draw_buffer.get_left();
135-
client.y = m_draw_buffer.get_top();
134+
client.x = 0;
135+
client.y = 0;
136136
client.width = m_draw_buffer.get_width();
137137
client.height = m_draw_buffer.get_height();
138138
}

support/gtkmm4/html_widget.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <gtkmm.h>
44
#include "html_host.h"
55
#include "web_page.h"
6-
#include "http_requests_pool.h"
76
#include "web_history.h"
87
#include "draw_buffer.h"
98
#include <queue>

support/webpage/web_page.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,22 @@ void litebrowser::text_file::on_page_downloaded(u_int32_t http_status,
2323

2424
void litebrowser::web_page::open(const std::string &url, const std::string &hash)
2525
{
26-
m_url = url;
27-
m_base_url = url;
26+
litehtml::url l_url(url);
27+
28+
if(!l_url.has_scheme())
29+
{
30+
if(url.front() != '/')
31+
{
32+
m_url = "http://" + url;
33+
} else
34+
{
35+
m_url = url;
36+
}
37+
} else
38+
{
39+
m_url = url;
40+
}
41+
m_base_url = m_url;
2842
m_hash = hash;
2943

3044
auto data = std::make_shared<text_file>();

0 commit comments

Comments
 (0)