File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ so please check *Changed* and *Removed* notes before upgrading.
88
99### Fixed
1010- Correct lookup issue caused by partial shared key with glob [ #23 ] ( https://github.com/luislavena/radix/issues/23 )
11+ - Correct lookup caused by non-root key in suffix [ #27 ] ( https://github.com/luislavena/radix/issues/27 )
1112
1213### Removed
1314- Remove ` Radix::Result#key ` since exposes internal details about structure (breaking change)
Original file line number Diff line number Diff line change @@ -353,6 +353,15 @@ module Radix
353353 result.found?.should be_true
354354 result.payload.should eq(:tags )
355355 end
356+
357+ it " do not find when lookup for non-root key" do
358+ tree = Tree (Symbol ).new
359+ tree.add " /prefix/" , :prefix
360+ tree.add " /prefix/foo" , :foo
361+
362+ result = tree.find " /foo"
363+ result.found?.should be_false
364+ end
356365 end
357366
358367 context " unicode nodes with shared parent" do
Original file line number Diff line number Diff line change @@ -299,6 +299,14 @@ module Radix
299299 end
300300 end
301301
302+ # determine if remaining part of key and path are still the same
303+ if (key_reader.has_next? && path_reader.has_next?) &&
304+ (key_reader.current_char != path_reader.current_char ||
305+ key_reader.peek_next_char != path_reader.peek_next_char)
306+ # path and key differ, skipping
307+ return
308+ end
309+
302310 # still path to walk, check for possible trailing slash or children
303311 # nodes
304312 if path_reader.has_next?
You can’t perform that action at this time.
0 commit comments