honojs/hono

Parameters being matched against before other paths if they weren't declared last

Closed this issue · 3 comments

What is the feature you are proposing?

I had a path/:id and a path/another. Declared in that order, and then spend an hour trying to debug it. Can't possibly that big of a performance hit to reorder paths for matching with param paths being last.

Reordered as in sorted by hono.

IMO this is not intuitive as most users would expect what is being declared first to be matched first.

Can't possibly that big of a performance hit to reorder paths for matching with param paths being last.

The complexity and performance hit is bigger than you think on large apps, especially when we consider the proper priority parsing of normal, path parameter, regexp, wildcard, etc.

If this is a blocker for you though, you can write a simple helper function that accesses the app.routes and app.router to perform the sorting to your liking.