-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(router): fallback for method-shadowed routes #461
Conversation
Codecov Report
@@ Coverage Diff @@
## main #461 +/- ##
==========================================
+ Coverage 78.38% 78.47% +0.09%
==========================================
Files 26 26
Lines 2803 2834 +31
Branches 408 414 +6
==========================================
+ Hits 2197 2224 +27
- Misses 606 610 +4
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great !
I was thinking if the name catchAll wouldn't be more fitting than shadow, but maybe there's a use case that doesn't involve **
that I'm not aware of ?
All nitro route rules use this feature to catch matching paths :) Marking PR as draft since I'm not still sure if this is best approach for fixing the issue |
Update: Spent couple of minutes trying different data structures and methods for radix3 and router implementations. There was to experiments:
This can cause side effects, especially for routes being registered with
It adds a function calling overhead per-request per-tree-node. Ideally this would be the best if radix3 natively supports methods. Therefore i think we can move forward with this (dirty) workaround as fix until shipping native method matching for radix3 (unjs/rou3#58) |
π Linked issue
Resolves #460
β Type of change
π Description
This PR resolves router issue with multiple routes matching shadowing their method by using a (lazy initialized) multi-matcher.
Performance note: While this adds small overhead, the prefix matcher is really fast specially for static routes (without params) which are usually the usecase for this feature for implementing renderer fallback routes. Regardless it is super fast and used for nitro route rules matcher as well (src).Performance: After first resolution of method-shadowed match, we update main match with missing method. This means that, only once (in server lifecycle) the resolution will happen.
π Checklist