Skip to content

Commit 81bfa7d

Browse files
authored
fix(sidebars): use startsWith to extract basePath instead of split (#1368)
String.split(doc) matched doc as a substring, so outputDir paths like "docs/test/docspace" with docPath "docs" would split on the second occurrence of "doc" inside "docspace", producing double slashes or missing path segments in generated sidebar IDs. Replacing with startsWith + substring ensures only the exact path prefix is stripped at a path boundary. Closes #1305
1 parent 21e6ede commit 81bfa7d

File tree

1 file changed

+2
-2
lines changed
  • packages/docusaurus-plugin-openapi-docs/src/sidebars

1 file changed

+2
-2
lines changed

packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ function groupByTags(
131131
output: string,
132132
doc: string | undefined
133133
): string => {
134-
if (doc && output.includes(doc)) {
135-
return output.split(doc)[1]?.replace(/^\/+/g, "") ?? "";
134+
if (doc && output.startsWith(doc + "/")) {
135+
return output.substring((doc + "/").length);
136136
}
137137
const slashIndex = output.indexOf("/", 1);
138138
return slashIndex === -1

0 commit comments

Comments
 (0)