Repository navigation
Conversation
indexDirs is keyed by directory path, but the guard checked the route basename, so it never matched and every later root overwrote the earlier one for the same directory. With wildcard: false and multiple roots, a directory request was served from the lowest-priority root instead of the highest, against the documented first found, first served order. Fixes fastify#617
Member
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.
Fixes #617
With
wildcard: falseand more than onerootdirectory, a request for a directory was served fromthe lowest-priority root instead of the highest — the opposite of the documented "first found,
first served" order.
indexDirsis keyed by directory path, but the guard looked up the route's basename:A filename is never a key in
indexDirs, so!indexDirs.has(key)was always true and each laterroot overwrote the entry for the same directory.
Change
Look up the directory the entry is actually stored under:
Test
Added a test with two roots —
root1/sub/index.htmandroot2/sub/index.html,index: ['index.htm', 'index.html'],wildcard: false— asserting thatGET /sub/serves root1'sfile. It returns
from root2before the change andfrom root1after.Note on the local run
npm run test:unitreports 99.7% line coverage here, all of it fromlib/dirList.js. That comesfrom two symlink tests that cannot create symlinks without elevated privileges on Windows, and it
reproduces identically on an unmodified checkout.
index.jsis at 100% in both cases.