Skip to content

Commit b2153a9

Browse files
MacDuenico
authored andcommitted
Help: Use handle_custom_scheme for help:// URLs
1 parent 5ea8707 commit b2153a9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Userland/Applications/Help/MainWidget.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,37 +118,38 @@ ErrorOr<void> MainWidget::initialize(GUI::Window& window)
118118

119119
m_web_view = find_descendant_of_type_named<WebView::OutOfProcessWebView>("web_view");
120120
m_web_view->use_native_user_style_sheet();
121-
m_web_view->on_link_click = [this](auto& url, auto&, unsigned) {
121+
m_web_view->handle_custom_scheme = [this](auto& url) {
122122
if (url.scheme() == "file") {
123123
auto path = LexicalPath { URL::percent_decode(url.serialize_path()) };
124124
if (!path.is_child_of(Manual::manual_base_path)) {
125125
open_external(url);
126-
return;
126+
return true;
127127
}
128128
auto browse_view_index = m_manual_model->index_from_path(path.string());
129129
if (browse_view_index.has_value()) {
130130
dbgln("Found path _{}_ in m_manual_model at index {}", path, browse_view_index.value());
131131
m_browse_view->selection().set(browse_view_index.value());
132-
return;
132+
return true;
133133
}
134134
m_history.push(path.string());
135135
auto string_path = String::from_byte_string(path.string());
136136
if (string_path.is_error())
137-
return;
137+
return true;
138138
open_page(string_path.value());
139139
} else if (url.scheme() == "help") {
140140
auto maybe_page = Manual::Node::try_find_from_help_url(url);
141141
if (maybe_page.is_error()) {
142142
dbgln("Error opening page: {}", maybe_page.error());
143-
return;
143+
return true;
144144
}
145145
auto maybe_path = maybe_page.value()->path();
146146
if (maybe_path.is_error())
147-
return;
147+
return true;
148148
open_page(maybe_path.release_value());
149149
} else {
150150
open_external(url);
151151
}
152+
return true;
152153
};
153154
m_web_view->on_context_menu_request = [this](auto screen_position) {
154155
m_copy_action->set_enabled(!m_web_view->selected_text().is_empty());

0 commit comments

Comments
 (0)