Skip to content
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

Lower named and glob node priority to fix lookup issue #17

Merged
merged 1 commit into from
Jan 18, 2017

Conversation

luislavena
Copy link
Owner

@luislavena luislavena commented Jan 17, 2017

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

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
@luislavena luislavena force-pushed the fix-sorting-named-parameters branch from 5a6811e to 9163860 Compare January 17, 2017 17:40
@luislavena luislavena merged commit 1eabf1a into master Jan 18, 2017
@luislavena luislavena deleted the fix-sorting-named-parameters branch January 18, 2017 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant