File tree Expand file tree Collapse file tree 4 files changed +21
-2
lines changed
Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 11# Changes
22
3+ ## [0.3.3] - 2020-04-11
4+
5+ * Fix `/` prefix match
6+
37## [0.3.2] - 2020-04-06
48
59* Fix IdxSegment item for paths with no root
Original file line number Diff line number Diff line change 11[package ]
22name = " ntex-router"
3- version = " 0.3.2 "
3+ version = " 0.3.3 "
44authors = [" Nikolay Kim <fafhrd91@gmail.com>" ]
55description = " Path router"
66keywords = [" ntex" ]
Original file line number Diff line number Diff line change @@ -761,6 +761,11 @@ mod tests {
761761
762762 #[ test]
763763 fn test_resource_prefix ( ) {
764+ let tree = Tree :: new ( & ResourceDef :: prefix ( "/" ) , 1 ) ;
765+ assert_eq ! ( tree. find( & mut Path :: new( "/" ) ) , Some ( 1 ) ) ;
766+ assert_eq ! ( tree. find( & mut Path :: new( "/a" ) ) , Some ( 1 ) ) ;
767+ assert_eq ! ( tree. find( & mut Path :: new( "/a/test/test" ) ) , Some ( 1 ) ) ;
768+
764769 let tree = Tree :: new ( & ResourceDef :: prefix ( "/name" ) , 1 ) ;
765770 assert_eq ! ( tree. find( & mut Path :: new( "/name" ) ) , Some ( 1 ) ) ;
766771 assert_eq ! ( tree. find( & mut Path :: new( "/name/" ) ) , Some ( 1 ) ) ;
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ impl Tree {
208208 if path == "/" {
209209 for val in & self . value {
210210 let v = match val {
211- Value :: Slesh ( v) | Value :: Prefix ( v) => * v,
211+ Value :: Slesh ( v) | Value :: Prefix ( v) | Value :: PrefixSlesh ( v ) => * v,
212212 _ => continue ,
213213 } ;
214214 if check ( v, resource) {
@@ -225,6 +225,16 @@ impl Tree {
225225 return Some ( v) ;
226226 }
227227 }
228+ } else {
229+ for val in & self . value {
230+ let v = match val {
231+ Value :: PrefixSlesh ( v) => * v,
232+ _ => continue ,
233+ } ;
234+ if check ( v, resource) {
235+ return Some ( v) ;
236+ }
237+ }
228238 }
229239
230240 let path = if path. starts_with ( '/' ) {
You can’t perform that action at this time.
0 commit comments