mirror of
https://github.com/elysiajs/elysia
synced 2026-08-09 12:35:48 +00:00
🔧 fix: #1752 system router with trailing path doesn't match with non-trailing
This commit is contained in:
@@ -192,8 +192,8 @@ const mergeRoutes = (r1: Routes, r2?: Routes) => {
|
||||
return r1
|
||||
}
|
||||
|
||||
// https://github.com/elysiajs/elysia/issues/1752
|
||||
// Bun.routes need to be sort for some reason?
|
||||
// // https://github.com/elysiajs/elysia/issues/1752
|
||||
// inconsistent behavior between trailing slash and non-trailing slash
|
||||
export const removeTrailingPath = (routes: Routes) => {
|
||||
for (const key of Object.keys(routes)) {
|
||||
if (key.charCodeAt(key.length - 1) === 47) {
|
||||
|
||||
@@ -311,7 +311,8 @@ describe('Bun router', () => {
|
||||
expect(response).toBe('OK!! XD')
|
||||
})
|
||||
|
||||
it('mapEarlyResponse onRequest', async () => {
|
||||
// https://github.com/elysiajs/elysia/issues/1752
|
||||
it('trailing slash should be consistent with non-trailing slash', async () => {
|
||||
const app = new Elysia()
|
||||
.get('/items/types/', () => '/items/types')
|
||||
.get('/items/types/:id', () => '/items/types/:id')
|
||||
|
||||
Reference in New Issue
Block a user