Skip to content

fix: improve path segment extraction for multi-instance docs - #1306

Closed
trofim24 wants to merge 1 commit into
PaloAltoNetworks:mainfrom
trofim24:main
Closed

trofim24 wants to merge 1 commit into
PaloAltoNetworks:mainfrom
trofim24:main

Conversation

@trofim24

@trofim24 trofim24 commented Feb 6, 2026

Copy link
Copy Markdown

Refactors the path extraction logic in both index.ts and sidebars/index.ts to use segment-by-segment matching instead of string splitting. This fixes edge cases where docPath appears multiple times in outputDir or when paths have inconsistent leading/trailing slashes.

Changes:

  • Normalize paths by removing leading ./ and leading/trailing slashes
  • Match docPath segments within outputDir segments sequentially
  • Clean up double slashes in the resulting infoBasePath

Fixes #1305

Description

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

Refactors the path extraction logic in both index.ts and sidebars/index.ts
to use segment-by-segment matching instead of string splitting. This fixes
edge cases where docPath appears multiple times in outputDir or when paths
have inconsistent leading/trailing slashes.

Changes:
- Normalize paths by removing leading ./ and leading/trailing slashes
- Match docPath segments within outputDir segments sequentially
- Clean up double slashes in the resulting infoBasePath

Fixes PaloAltoNetworks#1305
@sserrata

sserrata commented Oct 9, 2026

Copy link
Copy Markdown
Member

Thanks for digging into this, @trofim24, and sorry it sat so long. The sidebar part was fixed separately in #1368 (using a startsWith prefix match), so this branch now conflicts. The same substring-split bug is still in the infoPath calculation in index.ts, which produces broken Authentication links for output dirs like docs/test/docspace. We'll fix that in a follow-up that shares the #1368 helper between both places and adds tests, and we'll credit you there. Closing this one in favor of that.

@sserrata sserrata closed this Oct 9, 2026
sserrata added a commit that referenced this pull request Oct 9, 2026
The infoPath calculation split outputDir on docPath as a substring, so an
output dir such as "docs/test/docspace" produced "docs/test//<infoId>"
and broke the API explorer's Authentication link. Share the startsWith
helper from #1368 between the sidebar generator and infoPath, and skip
empty segments so a docs-root output dir no longer yields "//".

Supersedes #1306. Thanks to @trofim24 for the original report and fix.

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch had an error being deployed

1 failed deployment
default — c3c4ed38 Deployed Feb 6, 2026 by trofim24 via Analyze Unsafe (javascript) #1911
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: basePath generation breaks when outputDir folder names contain the configured docPath substring

2 participants