beego:fix the :id & * mixed router
Showing
2 changed files
with
7 additions
and
0 deletions
| ... | @@ -159,6 +159,10 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string, | ... | @@ -159,6 +159,10 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string, |
| 159 | iswild = true | 159 | iswild = true |
| 160 | regexpStr = seg | 160 | regexpStr = seg |
| 161 | } | 161 | } |
| 162 | if seg == "*" && len(wildcards) > 0 && reg == "" { | ||
| 163 | iswild = true | ||
| 164 | regexpStr = "(.+)" | ||
| 165 | } | ||
| 162 | if iswild { | 166 | if iswild { |
| 163 | if t.wildcard == nil { | 167 | if t.wildcard == nil { |
| 164 | t.wildcard = NewTree() | 168 | t.wildcard = NewTree() | ... | ... |
| ... | @@ -32,6 +32,9 @@ func init() { | ... | @@ -32,6 +32,9 @@ func init() { |
| 32 | routers = append(routers, testinfo{"/aa/*/bb", "/aa/2009/bb", map[string]string{":splat": "2009"}}) | 32 | routers = append(routers, testinfo{"/aa/*/bb", "/aa/2009/bb", map[string]string{":splat": "2009"}}) |
| 33 | routers = append(routers, testinfo{"/cc/*/dd", "/cc/2009/11/dd", map[string]string{":splat": "2009/11"}}) | 33 | routers = append(routers, testinfo{"/cc/*/dd", "/cc/2009/11/dd", map[string]string{":splat": "2009/11"}}) |
| 34 | routers = append(routers, testinfo{"/ee/:year/*/ff", "/ee/2009/11/ff", map[string]string{":year": "2009", ":splat": "11"}}) | 34 | routers = append(routers, testinfo{"/ee/:year/*/ff", "/ee/2009/11/ff", map[string]string{":year": "2009", ":splat": "11"}}) |
| 35 | routers = append(routers, testinfo{"/thumbnail/:size/uploads/*", | ||
| 36 | "/thumbnail/100x100/uploads/items/2014/04/20/dPRCdChkUd651t1Hvs18.jpg", | ||
| 37 | map[string]string{":size": "100x100", ":splat": "items/2014/04/20/dPRCdChkUd651t1Hvs18.jpg"}}) | ||
| 35 | routers = append(routers, testinfo{"/*.*", "/nice/api.json", map[string]string{":path": "nice/api", ":ext": "json"}}) | 38 | routers = append(routers, testinfo{"/*.*", "/nice/api.json", map[string]string{":path": "nice/api", ":ext": "json"}}) |
| 36 | routers = append(routers, testinfo{"/:name/*.*", "/nice/api.json", map[string]string{":name": "nice", ":path": "api", ":ext": "json"}}) | 39 | routers = append(routers, testinfo{"/:name/*.*", "/nice/api.json", map[string]string{":name": "nice", ":path": "api", ":ext": "json"}}) |
| 37 | routers = append(routers, testinfo{"/:name/test/*.*", "/nice/test/api.json", map[string]string{":name": "nice", ":path": "api", ":ext": "json"}}) | 40 | routers = append(routers, testinfo{"/:name/test/*.*", "/nice/test/api.json", map[string]string{":name": "nice", ":path": "api", ":ext": "json"}}) | ... | ... |
-
Please register or sign in to post a comment