Explorar o código

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 "/".
kleines Filmröllchen %!s(int64=2) %!d(string=hai) anos
pai
achega
b1eacf8801
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      Userland/Libraries/LibManual/Node.cpp

+ 2 - 1
Userland/Libraries/LibManual/Node.cpp

@@ -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)));
         }