-
Notifications
You must be signed in to change notification settings - Fork 4
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
Multiple paths not recognizing params? #9
Comments
Hi Michael, Thanks for the bug report. Unfortunately this does look like a bug in middler. I have reproduced it with a test and am looking into it now. |
Thanks @carlos8f. Great support as always ;) |
Actually, can you tell me if |
|
I removed the next and it still dispatches the |
If Two things to try:
|
It's actually a really strange bug. I tried to reproduce it using your tests but had no luck so far. Everything works as expected in your test. I did some testing in my add and found out that changing the order of middleware fixed my problem. But when i applied those changes to your test, it failed as expected. server
.post('/user/:id', mw2, mw3)
.post('/user/reset-password', [mw1]) It doesn't make sense to add the generic route first as the router can't differentiate between a parameter and the string (reset-password) then. Another thing i found out is that it might be caused by a generic middleware added as one of the first routes at I think it's some bug well hidden in my app. Were there any changes introduced with the latest middler which could cause such problems? Do you have a hint for me where to look for my bug? |
That is odd, it's the opposite of what should be happening. The latest middler is basically the same, but all the callback management got abstracted into a new module, bladerunner. I wouldn't think the refactor would cause this, but it's possible. Since the new middler doesn't have any improvements, we could revert the refactor if it's causing problems. But we need to reproduce with a test first.. When I run into stack issues like this, sometimes I make sure the functions are named, and console.log the handler function inside the loop so I can see which handlers match and which get skipped. |
I played with different middler versions and the bug appears only with
I'm not really sure why we couldn't reproduce the bug with your tests. My next few days are busy but maybe on the weekend or beginning of next week i might find some time to investigate further. |
Hey @carlos8f! Great to see there is a new version of middler.
I updated one of our projects and recognized that an integration-test fails with the latest version of middler. This might be related to the handling of multiple paths.
From you docs:
In my project there are two similar routes but one with
:params
and the other one with a static string:On a request to
/user/reset-password
therestrictHandler
of the second route triggers and it seems likeboth paths have been merged as middler thought it's the same path.
I have to admit that it's not good practice to mix methods (reset-password) and resources without consistent naming schemes.
But still there should be a difference between
params
and static paths when merging paths?Am i doing it wrong or is there a bug in middler?
cheers,
Michael
The text was updated successfully, but these errors were encountered: