#5406·hono

Custom LinearRouter and PatternRouter ignore strict trailing-slash routing

Author: haddybhaiyaCreated Sep 17, 2026Updated Sep 17, 2026

What version of Hono are you using?

4.13.8

What runtime/platform is your app running on? (with version if possible)

Node.js 22.23.2

What steps can reproduce the bug?

Use either LinearRouter or PatternRouter with the default strict: true setting:

typescript
import { Hono } from 'hono'
import { LinearRouter } from 'hono/router/linear-router'

const app = new Hono({ router: new LinearRouter() })
app.get('/hello', (c) => c.text('ok'))

const response = await app.request('http://localhost/hello/')
console.log(response.status)

The same happens with PatternRouter. It also affects parameter routes such as /users/:id when the request is /users/42/.

What is the expected behavior?

With strict routing enabled by default, a route should only match the same trailing-slash form. /hello should not match /hello/, and /hello/ should not match /hello.

RegExpRouter and TrieRouter already return 404 for those cases.

What do you see instead?

LinearRouter returns 200 for /hello matched against /hello/ and for /users/:id matched against /users/42/.

PatternRouter returns 200 for both directions, including /hello/ matched against /hello.

Additional information

The difference comes from LinearRouter accepting one trailing slash in its exact-route checks and PatternRouter adding an optional trailing slash to ordinary route patterns. This makes the public strict option depend on the selected router.