fix(core): strip trailing slash from _sourceFile in navDesignatedIndexFiles#131
Merged
mgks merged 1 commit intoMay 16, 2026
Conversation
…xFiles auto-router.js stores _sourceFile with a trailing slash (added by normalizeInternalHref), but generator.ts compares it against relWithoutExt which has no trailing slash. This causes Set.has() to always return false, so files promoted to folder-level nav URLs were never output at the folder path — resulting in a 404 when clicking those nav links. Fix: strip trailing slash when normalising _sourceFile before adding to the Set, making it consistent with relWithoutExt. Reproduces with any folder that contains .md files but no index.md: docs/SA/feature-discovery/my-page.md → nav link: /SA/feature-discovery (correct) → file output: /SA/feature-discovery/index.html (was missing, now fixed)
Member
|
Implementation verified. The fix correctly handles auto-designated index normalization by stripping the trailing slash to match the internal comparison format. Great catch, merging! |
This was referenced May 16, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
When a folder contains
.mdfiles but noindex.md, the auto-router promotes the first file to the folder-level URL (e.g._sourceFileis stored,pathis reassigned tobasePath). However, clicking that nav link results in a 404.Root Cause
In
auto-router.ts,normalizeInternalHref()adds a trailing slash tolinkPathbefore it is stored as_sourceFile:In
generator.ts, the Set is populated by stripping the leading slash only:But
relWithoutExt(the key used in.has()) has no trailing slash:So
navDesignatedIndexFiles.has(relWithoutExt)is alwaysfalse, meaningisNavDesignatedIndexis never set,effectivelyIndexstaysfalse, and the file is output atSA/feature-discovery/feature-active-reward-edit/index.htmlinstead of the intendedSA/feature-discovery/index.html.Result: nav link
/SA/feature-discoveryhas no matchingindex.html→ 404.Reproduction
Expected: clicking
feature-discoveryin the sidebar →200(content ofmy-page.md)Actual: 404 (
site/SA/feature-discovery/index.htmlis never generated)Fix
Strip the trailing slash when normalising
_sourceFilebefore adding to the Set, making it consistent withrelWithoutExt:Tested
index.mdworkaround from a project foldersite/SA/feature-discovery/index.htmlnow generated correctly/SA/feature-discovery→ HTTP 200 ✓