LibManual: Trim page name correctly when full path is provided

We would previously add an extra "/" at the beginning, since the section
name end points exactly at the found "/".
This commit is contained in:
kleines Filmröllchen 2023-07-02 13:22:29 +02:00 committed by Linus Groh
parent dfd0942e41
commit b1eacf8801

View file

@ -53,7 +53,8 @@ ErrorOr<NonnullRefPtr<PageNode const>> Node::try_create_from_query(Vector<String
auto section_name = section_directory.substring_view(section_name_start_index, section_name_end_index.value() - section_name_start_index);
auto section = TRY(SectionNode::try_create_from_number(section_name));
auto page_name_end_index = section_directory.length() - section_name_end_index.value() - MARKDOWN_FILE_EXTENSION.length() - 1;
auto page_name = section_directory.substring_view(section_name_end_index.value(), page_name_end_index);
// +1 to trim the leading '/' from the start.
auto page_name = section_directory.substring_view(section_name_end_index.value() + 1, page_name_end_index - 1);
return try_make_ref_counted<PageNode>(section, TRY(String::from_utf8(page_name)));
}