fix: only strip a whole index segment in the fs router - #2315
Merged
Conversation
Route files whose names merely end in "index" (e.g. `routes/reindex.tsx`) were mapped to `/re` instead of `/reindex` because both file routers used an unanchored `/index$/` replace. Anchor the strip to a segment boundary and share one implementation between the client and server routers. Fixes #2314 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: bd101eb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for solid-start-landing-page ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
birkskyum
approved these changes
Sep 10, 2026
birkskyum
pushed a commit
to solidjs/filesystem-routing
that referenced
this pull request
Sep 10, 2026
Route files whose names merely end in "index" (e.g. `routes/reindex.tsx`) were mapped to `/re` instead of `/reindex` because the nested convention used an unanchored `/index$/` replace. Anchor the strip to a segment boundary so only a real `index` file maps to its directory's path. Same fix as solidjs/solid-start#2315 for solidjs/solid-start#2314. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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.
PR Checklist
Please check if your PR fulfills the following requirements:
What is the current behavior?
Both file routers map a route file to its path with an unanchored
.replace(/index$/, ""), so any file whose name merely ends withindexloses that suffix.routes/reindex.tsxis registered at/reand/reindex404s;routes/myindex.tsxends up at/my. Nested directory indexes (reindex/index.tsx→/reindex/) happen to work, which masked the bug.Reproduced on
mainin dev and in a production build with a fixture containingreindex.tsx,myindex.tsx,appendix.tsx,blog/index.tsxand a[...404].tsxcatch-all:/reindexand/myindexreturned 404 while/reand/myserved those pages.What is the new behavior?
The trailing
indexis only stripped when it is a whole path segment (/(^|\/)index$/), soreindex.tsx→/reindexandblog/reindex.tsx→/blog/reindex. True index files are unchanged (index.tsx→/,blog/index.tsx→/blog/,[id]/index.tsx→/:id/).The two byte-identical
toPathimplementations inSolidStartClientFileRouterandSolidStartServerFileRouternow share a singletoRoutePathhelper so they cannot drift again.Other information
toPathcases inrouter.spec.tsrun against both routers: 7 cases pin the existing mapping (index files, plain, dynamic, optional and catch-all segments) and 5 cover the regression./reindexand/myindexreturn 200 in dev and prod,/reand/myfall through to the 404 route, and index routes still resolve.vitest run(114 tests),tsc --noEmitandoxfmt --checkare clean. Changeset included (patch).🤖 Generated with Claude Code