-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Unexpected param parsing with optional url parameters #1363
Comments
First of all, you should use |
Hi @namusyaka thanks for replying. The optional parameter is
I would argue the context is the most specific route. In fact that is also what the readme states (or at least that is how I interpret it):
Bug or not, IMHO it makes most sense that filters work from within that context. I can't think of a context or situation where I do want param values to differ between filter and route? |
Sorry for your confusing. I wanted to say that the optional parameter should be
Actually the patterns in the route and the filter are not necessarily closely related. |
Hmm okay. I did not consider that. It still feels strange though to have a param's value differ in a filter and route in a single request... Well anyway if this is the way it should work, than indeed it is not a bug. Thanks for taking the time to look into this! Feel free to close this issue if you consider it handled. |
I'm going to close this, as it looks resolved, and there's no concrete info about next steps. We can always discuss the API design in new issues or in the discussions. |
While investigating #1361 I found the following which I think is a separate issue. Since this issue also occurs in Sinatra 1.4.8 I don't know if this is by design or not, but imho it leads to unexpected behaviour.
I think it boils down to the fact that Sinatra should let the most specific route match do the parameter parsing and use those parsed values for the filters (like
before
). Not doing so will cause possible different param values for the same param in filters (before
) and the verbs (get
,post
etc)Testcase:
This test will fail, meaning that in the
before
filterbaz
yields to1
but in the actual route it isnil
.The text was updated successfully, but these errors were encountered: