Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun.FileSystemRouter router match unknown behaviour #12206

Open
AlbertSabate opened this issue Jun 27, 2024 · 0 comments
Open

Bun.FileSystemRouter router match unknown behaviour #12206

AlbertSabate opened this issue Jun 27, 2024 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@AlbertSabate
Copy link

AlbertSabate commented Jun 27, 2024

What version of Bun is running?

1.1.17

What platform is your computer?

Darwin 23.5.0 x86_64 i386

What steps can reproduce the bug?

Create a bun project with FileSystemRouter:

Files created (narrowed down):

  • src/pages/admin/[businessId]
  • src/pages/admin/[businessId]/providers
  • src/pages/admin/[businessId]/providers/create
  • src/pages/admin/[businessId]/providers/[providerId]/edit
  • src/pages/admin/[businessId]/providers/[providerId]/delete

Create file on process.cwd() - for example test.js:

const router = new Bun.FileSystemRouter({
  style: "nextjs",
  dir: process.cwd() + '/src/pages',
});

const route = router.match('http://localhost:3001/admin/6679fbe17b41431a977163fd/providers/create');
console.log(router);
console.log(route);

What is the expected behavior?

My expectation is the definition of the documentation.
https://bun.sh/docs/api/file-system-router

  • params Record<string, string> and not Record<string, string[]>
  • When and how does a match params or query become a string[]? - Should not return Record<string, string[]>. Or this should be properly defined.
  • params and the query return the same information. Should return as documented on the above link.
MatchedRoute {
  filePath: "/xxxxxx/src/pages/admin/[businessId]/providers/create.tsx",
  kind: "dynamic",
  name: "/admin/[businessId]/providers/create",
  params: {
    businessId: "6679fbe17b41431a977163fd",
  },
  pathname: "/admin/6679fbe17b41431a977163fd/providers/create",
  query: {},
  scriptSrc: "admin/[businessId]/providers/create.tsx",
  src: "admin/[businessId]/providers/create.tsx",
}

What do you see instead?

MatchedRoute {
  filePath: "/xxxxxx/src/pages/admin/[businessId]/providers/create.tsx",
  kind: "dynamic",
  name: "/admin/[businessId]/providers/create",
  params: {
    businessId: [ "6679fbe17b41431a977163fd", "6679fbe17b41431a977163fd" ],
  },
  pathname: "/admin/6679fbe17b41431a977163fd/providers/create",
  query: {
    businessId: [ "6679fbe17b41431a977163fd", "6679fbe17b41431a977163fd" ],
  },
  scriptSrc: "admin/[businessId]/providers/create.tsx",
  src: "admin/[businessId]/providers/create.tsx",
}

Additional information

  • src/pages/admin/[businessId]
    Works as expected

  • src/pages/admin/[businessId]/providers/create
    Does not work as expected

@AlbertSabate AlbertSabate added bug Something isn't working needs triage labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant