-
Notifications
You must be signed in to change notification settings - Fork 11
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
implemented same path wildcard & static conflict fix #29
base: main
Are you sure you want to change the base?
implemented same path wildcard & static conflict fix #29
Conversation
- implemented support of having exact route definitions for the same path as wildcard; - adjusted test to cover the case; - added .idea to .gitignore;
Hm, will look at it in the morning. Tests were passing on my local using node v20. Will check & fix |
Your fix allows some crazy router definitions like:
|
@steambap Could you please explain why the routes are crazy? I've rolled out few fixes:
|
What about routers like this:
It is true that |
Okay, got it. What is the reasoning behind this? Why won't we allow multiple wildcards if they have a different prefix? It's the same performance for |
I think it's confusing. There are probably multiple ways to make route paths harder to read like:
Also, you mentioned performance. Backtrack search in this PR reduce performance by 1/10 ~ 1/3 in the router benchmark linked in readme, although the benchmark does not test anything that requires backtrack. |
I agree that these routes are confusing, but I think it's 100% in the field of a tool user's responsibility, same as following correct REST route practices etc. It's all about code quality which must not be fixed by tools. Tools must provide functionality and I don't see a reason restricting it since exact/wildcard routes matching in similar paths is supported in most of well-known routers.
Oh, got it. Thanks for noticing. I will review performance and make changes then. |
@steambap I have done some optimizations, significantly improving performance. Now it runs with the same or +- same performance. macOS, M1 Pro (arm), Node v20 Before fix:First run:
Second run:
After fix
|
If this is a regex based router, I agree with you. We should provide user the tool to write |
Short:
Notes:
Fixes #28
Probably fixes: #19