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
{
"hash.:dest": "echo-bravo-delta.location",
"batch": "123",
"type": "o"
}
{
"hash.:dest": "echo-bravo-delta.location",
"batch": "123",
"type": "o"
}
I've tried escaping the period, and a variety of expressions that don't really help. Any suggestions?
12 Replies
ambergristle
ambergristle4w ago
hi @kingmesal! can you share more about your routing setup, and which hono router you're using?
kingmesal
kingmesalOP4w ago
default router setup. the route is handled properly with that but the params are not parsed correctly
ambergristle
ambergristle4w ago
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?
kingmesal
kingmesalOP4w ago
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
{
"hash.:dest": "echo-bravo-delta.location",
"batch": "123",
"type": "o"
}
{
"hash.:dest": "echo-bravo-delta.location",
"batch": "123",
"type": "o"
}
is there a way I can adjust the route configuration to produce
{
"dest": "location",
"hash": "echo-bravo-delta",
"batch": "123",
"type": "o"
}
{
"dest": "location",
"hash": "echo-bravo-delta",
"batch": "123",
"type": "o"
}
ambergristle
ambergristle4w ago
is :hash.:dest handled by a single endpoint?
kingmesal
kingmesalOP4w ago
yes
ambergristle
ambergristle4w ago
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 token
kingmesal
kingmesalOP4w ago
yeah .. odd that it routes properly, but the params doesn't split properly param parsing is decoupled from routing table, right?
ambergristle
ambergristle4w ago
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
kingmesal
kingmesalOP4w ago
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...
ambergristle
ambergristle4w ago
nice! idk how common that pattern is, but i'm looking forward to seeing what the community has to say!
EdamAmex
EdamAmex4w ago
hmm

Did you find this page helpful?