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

Duplicate Routes and Incorrect Path Handling in Elysia Framework #938

Open
PandaWorker opened this issue Dec 9, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@PandaWorker
Copy link

PandaWorker commented Dec 9, 2024

What version of Elysia is running?

1.1.26

What platform is your computer?

No response

What steps can reproduce the bug?

import { swagger } from '@elysiajs/swagger';
import { Elysia } from 'elysia';

const publicApi2 = new Elysia({
	name: 'public',
	prefix: '/',
	tags: ['Public API'],
}).get('/', () => 200);

const publicApi = new Elysia({
	name: 'public',
	prefix: '/',
	tags: ['Public API'],
})
	.get('/', () => 200)
	.use(publicApi2);

const app = new Elysia()
	.use(swagger({ path: '/docs', provider: 'swagger-ui' }))
	.use(publicApi);

console.log(app.routes.map(({hooks, ...route}) => (route)));

What is the expected behavior?

[
  {
    method: 'GET',
    path: '/',
    composed: [Function (anonymous)],
    handler: [Function (anonymous)]
  }
]

What do you see instead?

[
  {
    method: 'GET',
    path: '//',
    composed: [Function (anonymous)],
    handler: [Function (anonymous)]
  },
  {
    method: 'GET',
    path: '///',
    composed: [Function (anonymous)],
    handler: [Function (anonymous)]
  }
]

Additional information

The issue seems to be related to how the prefix and nested routes are being handled.

The extra / in the path is likely causing the routes to be incorrectly registered.

Have you try removing the node_modules and bun.lockb and try again yet?

No response

@PandaWorker PandaWorker added the bug Something isn't working label Dec 9, 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
Projects
None yet
Development

No branches or pull requests

1 participant