honojs / hono

Web framework built on Web Standards
https://hono.dev
MIT License
20.31k stars 579 forks source link

Route defined by multiple paths not handled #2422

Closed thonythony closed 7 months ago

thonythony commented 7 months ago

What version of Hono are you using?

3.11.2

What runtime/platform is your app running on?

Cloudflare Workers

What steps can reproduce the bug?

Hello,

Define a route with multiple paths like this :

app.on(
  'GET',
  [
    '/blog/*',
    ...LANGUAGES.map((lang) => `/${lang}/blog/*`),
    '/_elderjs/*',
    ...LANGUAGES.map((lang) => `/${lang}/_elderjs/*`),
  ],
  ...proxifyBlogMiddleware(),
)

What is the expected behavior?

The handle should be called when matching following routes :

What do you see instead?

A 404 is returned.

Additional information

If I define routes like this :

const blogRoutes = [
  '/blog/*',
  ...LANGUAGES.map((lang) => `/${lang}/blog/*`),
  '/_elderjs/*',
  ...LANGUAGES.map((lang) => `/${lang}/_elderjs/*`),
]

for (const route of blogRoutes) {
  app.get(route, ...proxifyBlogMiddleware())
}

Everything works as expected.

yusukebe commented 7 months ago

Hi @thonythony

With only the description, we can't determine where is not working. So please provide a minimal example or minimal project for reproducing.

yusukebe commented 7 months ago

No response, so I'll close this.