mirror of
https://gitea.invidious.io/iv-org/shard-radix.git
synced 2024-08-15 00:43:21 +00:00
Correct lookup with shared key and glob
Properly skip nodes and continue lookup when the key to be looked up shares partial elements with others. With the following scenario: tree = Radix::Tree(Symbol).new tree.add "/*glob", :catch_all tree.add "/resources", :resources tree.add "/robots.txt", :robots When attempt to lookup for `/reviews`, it will now correctly return `:catch_all` as found. Fixes #23
This commit is contained in:
parent
edcdddcd73
commit
93247cd33a
3 changed files with 26 additions and 6 deletions
|
@ -451,6 +451,19 @@ module Radix
|
|||
result.params.has_key?("anything").should be_true
|
||||
result.params["anything"].should eq("cancelled")
|
||||
end
|
||||
|
||||
it "does prefer root catch all over specific partially shared key" do
|
||||
tree = Tree(Symbol).new
|
||||
tree.add "/*anything", :root_catch_all
|
||||
tree.add "/robots.txt", :robots
|
||||
tree.add "/resources", :resources
|
||||
|
||||
result = tree.find("/reviews")
|
||||
result.found?.should be_true
|
||||
result.payload.should eq(:root_catch_all)
|
||||
result.params.has_key?("anything").should be_true
|
||||
result.params["anything"].should eq("reviews")
|
||||
end
|
||||
end
|
||||
|
||||
context "dealing with named parameters" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue