From 5ad999a3d177832162c1c3bbc164c652208c7d85 Mon Sep 17 00:00:00 2001 From: Yongzheng Lai Date: Sun, 6 Sep 2015 12:01:50 +0800 Subject: [PATCH 1/5] Update tree.go fix routers for: ``` /topic/:id/?:auth /topic/:id/?:auth:int ``` --- tree.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tree.go b/tree.go index e0d9c1c2..f15af91a 100644 --- a/tree.go +++ b/tree.go @@ -208,6 +208,11 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string, } else { t.leaves = append(t.leaves, &leafInfo{runObject: route, wildcards: wildcards}) } + for i, v := range wildcards { + if v==":" && i!=0{ + t.leaves = append(t.leaves, &leafInfo{runObject: route, wildcards: wildcards[:i+1]}) + } + } } else { seg := segments[0] iswild, params, regexpStr := splitSegment(seg) From 508a57be1efa3a4638ba4729f2f4e63c3a18d6bb Mon Sep 17 00:00:00 2001 From: Yongzheng Lai Date: Sun, 6 Sep 2015 12:07:12 +0800 Subject: [PATCH 2/5] Update tree_test.go --- tree_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tree_test.go b/tree_test.go index 1d2890e1..40065e77 100644 --- a/tree_test.go +++ b/tree_test.go @@ -26,6 +26,10 @@ var routers []testinfo func init() { routers = make([]testinfo, 0) + routers = append(routers, testinfo{"/topic/:id/?:auth", "/topic/1", map[string]string{":id": "1"}}) + routers = append(routers, testinfo{"/topic/:id/?:auth", "/topic/1/2", map[string]string{":id": "1",":auth":"2"}}) + routers = append(routers, testinfo{"/topic/:id/?:auth:int", "/topic/1", map[string]string{":id": "1"}}) + routers = append(routers, testinfo{"/topic/:id/?:auth:int", "/topic/1/123", map[string]string{":id": "1",":auth":"123"}}) routers = append(routers, testinfo{"/:id", "/123", map[string]string{":id": "123"}}) routers = append(routers, testinfo{"/hello/?:id", "/hello", map[string]string{":id": ""}}) routers = append(routers, testinfo{"/", "/", nil}) From ddd9bf1305635e499561a7dc4088acfbc9314873 Mon Sep 17 00:00:00 2001 From: Yongzheng Lai Date: Sun, 6 Sep 2015 12:16:05 +0800 Subject: [PATCH 3/5] Update tree.go --- tree.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tree.go b/tree.go index f15af91a..8f0df589 100644 --- a/tree.go +++ b/tree.go @@ -209,7 +209,7 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string, t.leaves = append(t.leaves, &leafInfo{runObject: route, wildcards: wildcards}) } for i, v := range wildcards { - if v==":" && i!=0{ + if v==":" { t.leaves = append(t.leaves, &leafInfo{runObject: route, wildcards: wildcards[:i+1]}) } } From 1377d16559e6e145958e0a0cf96cfdb614b2cd03 Mon Sep 17 00:00:00 2001 From: Yongzheng Lai Date: Sun, 6 Sep 2015 12:17:16 +0800 Subject: [PATCH 4/5] Update tree_test.go --- tree_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tree_test.go b/tree_test.go index 40065e77..7fe70f51 100644 --- a/tree_test.go +++ b/tree_test.go @@ -26,6 +26,8 @@ var routers []testinfo func init() { routers = make([]testinfo, 0) + routers = append(routers, testinfo{"/topic/?:auth:int", "/topic", nil}) + routers = append(routers, testinfo{"/topic/?:auth:int", "/topic/123", map[string]string{":auth":"123"}}) routers = append(routers, testinfo{"/topic/:id/?:auth", "/topic/1", map[string]string{":id": "1"}}) routers = append(routers, testinfo{"/topic/:id/?:auth", "/topic/1/2", map[string]string{":id": "1",":auth":"2"}}) routers = append(routers, testinfo{"/topic/:id/?:auth:int", "/topic/1", map[string]string{":id": "1"}}) From a2a6ec954b5a8ccb13b8b9b4cb600c8bac509791 Mon Sep 17 00:00:00 2001 From: Yongzheng Lai Date: Sun, 6 Sep 2015 22:13:58 +0800 Subject: [PATCH 5/5] Update tree.go go fmt --- tree.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tree.go b/tree.go index 8f0df589..46d05ae7 100644 --- a/tree.go +++ b/tree.go @@ -209,7 +209,7 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string, t.leaves = append(t.leaves, &leafInfo{runObject: route, wildcards: wildcards}) } for i, v := range wildcards { - if v==":" { + if v == ":" { t.leaves = append(t.leaves, &leafInfo{runObject: route, wildcards: wildcards[:i+1]}) } }