-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
query parameters oddness #293
Comments
This seems to be a bug in the router. WDYT @luislavena ? |
Can you try for get "/new_tag_edit_list2/" do |env| Add / before " do |
@sdogruyol looks like a bug in Radix: tree = Radix::Tree(Symbol).new
tree.add "/new_tag_edit_list/:id", :one
tree.add "/new_tag_edit_list2", :two
result = tree.find "/new_tag_edit_list2"
# this should be `true`
p result.found? # => false As a workaround for now I recommend changing the order on how the routes are defined. Will try to look at this in detail this week. Cheers. |
@luislavena it's interesting. If you add p.result it indeed prints out a radix node. tree = Radix::Tree(Symbol).new
tree.add "/new_tag_edit_list/:id", :one
tree.add "/new_tag_edit_list2", :two
result = tree.find "/new_tag_edit_list2"
# this should be `true`
p result.found? # => false
p result # #<Radix::Result(Symbol):0x55ccc1f68c80..,> The radix repo shows an earlier problem in November that seems related: luislavena/radix#14 |
Yes, because the nodes that were found are stacked up, but what is important is the value of
The actual issue is Cheers. |
Given two similar keys, one short and one with named parameter, lookup was incorretly picking up the named parameter version instead of the specific one: tree = Radix::Tree(Symbol).new tree.add "/tag-edit/:id", :edit_tag tree.add "/tag-edit2", :alternate_edit_tag result = tree.find("/tag-edit2") result.found? # => false The order of insertion (named before specific) was causing the lookup mechanism to validate it before checking the other options. With the changes present here, short or long keys will be affected anymore by named or globbed keys present when sharing part of the key. Fixes kemalcr/kemal#293
Given two similar keys, one short and one with named parameter, lookup was incorrectly picking up the named parameter version instead of the specific one: tree = Radix::Tree(Symbol).new tree.add "/tag-edit/:id", :edit_tag tree.add "/tag-edit2", :alternate_edit_tag result = tree.find("/tag-edit2") result.found? # => false The order of insertion (named before specific) was causing the lookup mechanism to validate it before checking the other options. With the changes present here, short or long keys will be affected anymore by named or globbed keys present when sharing part of the key. Fixes kemalcr/kemal#293
@rdp @sdogruyol just released Please try it and let me know if you encounter any issue. Cheers. |
@luislavena @rdp fixed on master 👍 |
OK that issue was fixed thanks! I do have one other small question, perhaps I should file a new issue do you think? With the following snippet (unrelated) I seem unable to access http://localhost:3000/edit_tag_edit_list/3 (404) anybody know if this is expected?
Thanks! |
@rdp same issue, caused by insertion order, change the order (define longer path first) and should work:
vs:
@sdogruyol |
Hello @rdp @sdogruyol, I've pushed a new version of Radix ( If interested, you can read all the details in luislavena/radix#18 and solution at luislavena/radix#19. Thank you for your report. ❤️ ❤️ ❤️ |
Thanks @luislavena 🙏 |
Awesome, thanks @luislavena and everybody, seems fixed now, perfect. |
Hello. I noticed with this snippet:
it returns a 404 for this path:
http://127.0.0.1:3000/new_tag_edit_list2
FWIW. Seems to also affect POST's etc. as well.
Making them not "match" in prefix and everything works again...
The text was updated successfully, but these errors were encountered: