mirror of
https://gitea.invidious.io/iv-org/shard-radix.git
synced 2024-08-15 00:43:21 +00:00
Fix incorrect lookup on non-shared partial keys
Given the following nodes in a tree: # ( 8) /product # ( 4) /new # ( 1) s tree = Radix::Tree(Symbol).new tree.add "/products", :products tree.add "/product/new", :product_new It failed to properly identify `/products` during lookup: result = tree.find "/products" result.found? # => false Caused by incorrect comparsion of `s` remaining path against `/new` node instead of continue comparison with the next one. Fixes #21
This commit is contained in:
parent
b81ac70758
commit
9895655a8a
3 changed files with 19 additions and 0 deletions
|
@ -323,6 +323,17 @@ module Radix
|
|||
result.payload.should eq(:abc)
|
||||
end
|
||||
|
||||
it "finds matching path across separator" do
|
||||
tree = Tree(Symbol).new
|
||||
tree.add "/products", :products
|
||||
tree.add "/product/new", :product_new
|
||||
|
||||
result = tree.find("/products")
|
||||
result.found?.should be_true
|
||||
result.key.should eq("/products")
|
||||
result.payload.should eq(:products)
|
||||
end
|
||||
|
||||
it "finds matching path across parents" do
|
||||
tree = Tree(Symbol).new
|
||||
tree.add "/", :root
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue