Hono Param Parsing - bug?
I have this route:
"/e/:type/:batch/:hash.:dest"
Hono routes this properly, however, it does NOT split the params properly
I've tried escaping the period, and a variety of expressions that don't really help. Any suggestions?12 Replies
hi @kingmesal! can you share more about your routing setup, and which hono router you're using?
default router setup.
the route is handled properly with that but the params are not parsed correctly
i'm not familiar with the use of dot delimiting in url paths. can you expand a bit on what you have going on there? what does it mean for that path to be handled properly?
as in, i add that route to the Hono app, and when I hit the end point, it goes into the code just fine... the problem is that
c.req.param()
produces
is there a way I can adjust the route configuration to produce
is
:hash.:dest
handled by a single endpoint?yes
gotcha. so at a glance, not all hono routers would even route that path correctly. the LinearRouter regex appears to disregard
.:dest
altogether: https://github.com/honojs/hono/blob/47bb23c575a93d5fed4721935481a6a4cbf5cf1a/src/router/linear-router/router.ts#L9
i see what you mean, that the RegExpRouter will match .:dest
, but doesn't create a capture group for the tokenyeah .. odd that it routes properly, but the params doesn't split properly
param parsing is decoupled from routing table, right?
nope
looks like it uses the match result to grab the tokens: https://github.com/honojs/hono/blob/47bb23c575a93d5fed4721935481a6a4cbf5cf1a/src/request.ts#L108
the param parser is working as expected, given the way that the regex in hono routers works
no idea why dot delimiting was handled this way
I have filed this
https://github.com/honojs/hono/issues/3745
GitHub
Param parsing with a dot in the path doesn't capture all the parame...
What version of Hono are you using? 4.6.12 What runtime/platform is your app running on? (with version if possible) Local What steps can reproduce the bug? Using the standard default Hono configura...
nice! idk how common that pattern is, but i'm looking forward to seeing what the community has to say!
hmm