|
@@ -7,6 +7,7 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
#include "MainWidget.h"
|
|
#include "MainWidget.h"
|
|
|
|
+#include <AK/URL.h>
|
|
#include <LibCore/ArgsParser.h>
|
|
#include <LibCore/ArgsParser.h>
|
|
#include <LibCore/System.h>
|
|
#include <LibCore/System.h>
|
|
#include <LibGUI/Application.h>
|
|
#include <LibGUI/Application.h>
|
|
@@ -16,6 +17,15 @@
|
|
|
|
|
|
using namespace Help;
|
|
using namespace Help;
|
|
|
|
|
|
|
|
+static String parse_input(char const* input)
|
|
|
|
+{
|
|
|
|
+ AK::URL url(input);
|
|
|
|
+ if (url.is_valid())
|
|
|
|
+ return url.basename();
|
|
|
|
+
|
|
|
|
+ return input;
|
|
|
|
+}
|
|
|
|
+
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
{
|
|
{
|
|
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix"));
|
|
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix"));
|
|
@@ -27,8 +37,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
TRY(Core::System::unveil("/tmp/portal/webcontent", "rw"));
|
|
TRY(Core::System::unveil("/tmp/portal/webcontent", "rw"));
|
|
TRY(Core::System::unveil(nullptr, nullptr));
|
|
TRY(Core::System::unveil(nullptr, nullptr));
|
|
|
|
|
|
- char const* start_page = nullptr;
|
|
|
|
- unsigned section = 0;
|
|
|
|
|
|
+ String start_page;
|
|
|
|
+ u32 section = 0;
|
|
|
|
|
|
Core::ArgsParser args_parser;
|
|
Core::ArgsParser args_parser;
|
|
// FIXME: These custom Args are a hack. What we want to do is have an optional int arg, then an optional string.
|
|
// FIXME: These custom Args are a hack. What we want to do is have an optional int arg, then an optional string.
|
|
@@ -47,7 +57,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
}
|
|
}
|
|
|
|
|
|
// Otherwise, use it as the start_page
|
|
// Otherwise, use it as the start_page
|
|
- start_page = input;
|
|
|
|
|
|
+ start_page = parse_input(input);
|
|
return true;
|
|
return true;
|
|
} });
|
|
} });
|
|
args_parser.add_positional_argument(Core::ArgsParser::Arg {
|
|
args_parser.add_positional_argument(Core::ArgsParser::Arg {
|
|
@@ -57,9 +67,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
.max_values = 1,
|
|
.max_values = 1,
|
|
.accept_value = [&](char const* input) {
|
|
.accept_value = [&](char const* input) {
|
|
// If start_page was already set by our section arg, then it can't be set again
|
|
// If start_page was already set by our section arg, then it can't be set again
|
|
- if (start_page)
|
|
|
|
|
|
+ if (start_page.is_empty())
|
|
return false;
|
|
return false;
|
|
- start_page = input;
|
|
|
|
|
|
+ start_page = parse_input(input);
|
|
return true;
|
|
return true;
|
|
} });
|
|
} });
|
|
args_parser.parse(arguments);
|
|
args_parser.parse(arguments);
|