From 53353fce56fe78b60c536e91df48808a9f8d0a73 Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 30 Jun 2014 23:49:11 +0800 Subject: [PATCH] beego:fix the :id & * mixed router --- tree.go | 4 ++++ tree_test.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/tree.go b/tree.go index 9d464225..f2bc6aa9 100644 --- a/tree.go +++ b/tree.go @@ -159,6 +159,10 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string, iswild = true regexpStr = seg } + if seg == "*" && len(wildcards) > 0 && reg == "" { + iswild = true + regexpStr = "(.+)" + } if iswild { if t.wildcard == nil { t.wildcard = NewTree() diff --git a/tree_test.go b/tree_test.go index 69da718a..0a30f677 100644 --- a/tree_test.go +++ b/tree_test.go @@ -32,6 +32,9 @@ func init() { routers = append(routers, testinfo{"/aa/*/bb", "/aa/2009/bb", map[string]string{":splat": "2009"}}) routers = append(routers, testinfo{"/cc/*/dd", "/cc/2009/11/dd", map[string]string{":splat": "2009/11"}}) routers = append(routers, testinfo{"/ee/:year/*/ff", "/ee/2009/11/ff", map[string]string{":year": "2009", ":splat": "11"}}) + routers = append(routers, testinfo{"/thumbnail/:size/uploads/*", + "/thumbnail/100x100/uploads/items/2014/04/20/dPRCdChkUd651t1Hvs18.jpg", + map[string]string{":size": "100x100", ":splat": "items/2014/04/20/dPRCdChkUd651t1Hvs18.jpg"}}) routers = append(routers, testinfo{"/*.*", "/nice/api.json", map[string]string{":path": "nice/api", ":ext": "json"}}) routers = append(routers, testinfo{"/:name/*.*", "/nice/api.json", map[string]string{":name": "nice", ":path": "api", ":ext": "json"}}) routers = append(routers, testinfo{"/:name/test/*.*", "/nice/test/api.json", map[string]string{":name": "nice", ":path": "api", ":ext": "json"}})