From 6561d614f7f2462a2fe162b99f78a6af58e85565 Mon Sep 17 00:00:00 2001 From: saltyaom Date: Wed, 25 Feb 2026 16:54:53 +0700 Subject: [PATCH] :wrench: fix: #1752 system router with trailing path doesn't match with non-trailing --- src/adapter/bun/index.ts | 4 ++-- test/bun/router.test.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/adapter/bun/index.ts b/src/adapter/bun/index.ts index 813a95f3..7e2697ef 100644 --- a/src/adapter/bun/index.ts +++ b/src/adapter/bun/index.ts @@ -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) { diff --git a/test/bun/router.test.ts b/test/bun/router.test.ts index 6284bc38..27555616 100644 --- a/test/bun/router.test.ts +++ b/test/bun/router.test.ts @@ -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')