🔧 fix: #1752 system router with trailing path doesn't match with non-trailing

This commit is contained in:
saltyaom
2026-02-25 16:54:53 +07:00
parent 3c9dabc474
commit 6561d614f7
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -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) {
+2 -1
View File
@@ -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')