diff --git a/Ladybird/Tab.cpp b/Ladybird/Tab.cpp index e8d1667fc4..7e1434768d 100644 --- a/Ladybird/Tab.cpp +++ b/Ladybird/Tab.cpp @@ -81,7 +81,13 @@ Tab::Tab(BrowserWindow* window, int webdriver_fd_passing_socket) forward(); }); - QObject::connect(m_view, &WebContentView::load_started, [this](const URL& url) { + QObject::connect(m_view, &WebContentView::load_started, [this](const URL& url, bool is_redirect) { + // If we are loading due to a redirect, we replace the current history entry + // with the loaded URL + if (is_redirect) { + m_history.replace_current(url, m_title.toUtf8().data()); + } + m_location_edit->setText(url.to_string().characters()); // Don't add to history if back or forward is pressed diff --git a/Ladybird/WebContentView.cpp b/Ladybird/WebContentView.cpp index 25789514da..f2b483601b 100644 --- a/Ladybird/WebContentView.cpp +++ b/Ladybird/WebContentView.cpp @@ -802,10 +802,10 @@ void WebContentView::notify_server_did_middle_click_link(Badge (void)modifiers; } -void WebContentView::notify_server_did_start_loading(Badge, AK::URL const& url) +void WebContentView::notify_server_did_start_loading(Badge, AK::URL const& url, bool is_redirect) { m_url = url; - emit load_started(url); + emit load_started(url, is_redirect); } void WebContentView::notify_server_did_finish_loading(Badge, AK::URL const& url) diff --git a/Ladybird/WebContentView.h b/Ladybird/WebContentView.h index 92bd790607..6f820e05d3 100644 --- a/Ladybird/WebContentView.h +++ b/Ladybird/WebContentView.h @@ -123,7 +123,7 @@ public: virtual void notify_server_did_unhover_link(Badge) override; virtual void notify_server_did_click_link(Badge, const AK::URL&, String const& target, unsigned modifiers) override; virtual void notify_server_did_middle_click_link(Badge, const AK::URL&, String const& target, unsigned modifiers) override; - virtual void notify_server_did_start_loading(Badge, const AK::URL&) override; + virtual void notify_server_did_start_loading(Badge, const AK::URL&, bool) override; virtual void notify_server_did_finish_loading(Badge, const AK::URL&) override; virtual void notify_server_did_request_navigate_back(Badge) override; virtual void notify_server_did_request_navigate_forward(Badge) override; @@ -163,7 +163,7 @@ signals: void link_unhovered(); void back_mouse_button(); void forward_mouse_button(); - void load_started(const URL&); + void load_started(const URL&, bool); void title_changed(QString); void favicon_changed(QIcon); void got_source(URL, QString);