1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-29 17:25:10 +00:00

LibManual: Allow querying on a help URL

This allows Help and man to open pages from a help URL specified on
the command line.
This commit is contained in:
Tim Ledbetter 2023-04-25 17:34:19 +01:00 committed by Andrew Kaster
parent 6ab13489ee
commit c09d0c4816

View file

@ -22,6 +22,12 @@ ErrorOr<NonnullRefPtr<PageNode const>> Node::try_create_from_query(Vector<String
if (query_parameters.size() > 2)
return Error::from_string_literal("Queries longer than 2 strings are not supported yet");
if (query_parameters.size() == 1 && query_parameters[0].starts_with("help://"sv)) {
auto help_url = URL::create_with_url_or_path(query_parameters[0].trim("/"sv, TrimMode::Right));
auto node_from_url = TRY(Manual::Node::try_find_from_help_url(help_url));
return *node_from_url->document();
}
auto query_parameter_iterator = query_parameters.begin();
if (query_parameter_iterator.is_end())