Skip to content

fix: only strip a whole index segment in the fs router - #2315

Merged
birkskyum merged 1 commit into
mainfrom
fix-2314-fs-router-index-suffix
Sep 10, 2026
Merged

fix: only strip a whole index segment in the fs router#2315
birkskyum merged 1 commit into
mainfrom
fix-2314-fs-router-index-suffix

Conversation

@brenelz

@brenelz brenelz commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

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 with index loses that suffix. routes/reindex.tsx is registered at /re and /reindex 404s; routes/myindex.tsx ends up at /my. Nested directory indexes (reindex/index.tsx/reindex/) happen to work, which masked the bug.

Reproduced on main in dev and in a production build with a fixture containing reindex.tsx, myindex.tsx, appendix.tsx, blog/index.tsx and a [...404].tsx catch-all: /reindex and /myindex returned 404 while /re and /my served those pages.

What is the new behavior?

The trailing index is only stripped when it is a whole path segment (/(^|\/)index$/), so reindex.tsx/reindex and blog/reindex.tsx/blog/reindex. True index files are unchanged (index.tsx/, blog/index.tsx/blog/, [id]/index.tsx/:id/).

The two byte-identical toPath implementations in SolidStartClientFileRouter and SolidStartServerFileRouter now share a single toRoutePath helper so they cannot drift again.

Other information

  • New toPath cases in router.spec.ts run against both routers: 7 cases pin the existing mapping (index files, plain, dynamic, optional and catch-all segments) and 5 cover the regression.
  • Verified with the fixture above after the change: /reindex and /myindex return 200 in dev and prod, /re and /my fall through to the 404 route, and index routes still resolve.
  • vitest run (114 tests), tsc --noEmit and oxfmt --check are clean. Changeset included (patch).

🤖 Generated with Claude Code

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-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bd101eb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/start Patch

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

@netlify

netlify Bot commented Sep 10, 2026

Copy link
Copy Markdown

Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit bd101eb
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6aa304885f89a800085835e8
😎 Deploy Preview https://deploy-preview-2315--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2315

commit: bd101eb

@birkskyum
birkskyum merged commit eca4cc4 into main Sep 10, 2026
13 checks passed
@birkskyum
birkskyum deleted the fix-2314-fs-router-index-suffix branch September 10, 2026 20:26
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>
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.

fs router strips any trailing "index" substring, mis-routing pages like reindex.tsx to /re

2 participants