mirror of
https://github.com/astaxie/beego.git
synced 2024-11-29 18:21:29 +00:00
Merge branch 'master' into develop
This commit is contained in:
commit
08b3e4191e
7
tree.go
7
tree.go
@ -237,13 +237,19 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string,
|
|||||||
regexpStr = "/" + regexpStr
|
regexpStr = "/" + regexpStr
|
||||||
}
|
}
|
||||||
} else if reg != "" {
|
} else if reg != "" {
|
||||||
|
if seg == "*.*" {
|
||||||
|
regexpStr = "/([^.]+).(.+)"
|
||||||
|
} else {
|
||||||
for _, w := range params {
|
for _, w := range params {
|
||||||
|
|
||||||
if w == "." || w == ":" {
|
if w == "." || w == ":" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
regexpStr = "/([^/]+)" + regexpStr
|
regexpStr = "/([^/]+)" + regexpStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
t.wildcard.addseg(segments[1:], route, append(wildcards, params...), reg+regexpStr)
|
t.wildcard.addseg(segments[1:], route, append(wildcards, params...), reg+regexpStr)
|
||||||
} else {
|
} else {
|
||||||
subTree, ok := t.fixrouters[seg]
|
subTree, ok := t.fixrouters[seg]
|
||||||
@ -396,6 +402,7 @@ func (leaf *leafInfo) match(wildcardValues []string) (ok bool, params map[string
|
|||||||
}
|
}
|
||||||
return true, params
|
return true, params
|
||||||
}
|
}
|
||||||
|
|
||||||
if !leaf.regexps.MatchString(path.Join(wildcardValues...)) {
|
if !leaf.regexps.MatchString(path.Join(wildcardValues...)) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,9 @@ func init() {
|
|||||||
routers = append(routers, testinfo{"/*.*", "/nice/api.json", map[string]string{":path": "nice/api", ":ext": "json"}})
|
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/*.*", "/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"}})
|
routers = append(routers, testinfo{"/:name/test/*.*", "/nice/test/api.json", map[string]string{":name": "nice", ":path": "api", ":ext": "json"}})
|
||||||
|
routers = append(routers, testinfo{"/dl/:width:int/:height:int/*.*",
|
||||||
|
"/dl/48/48/05ac66d9bda00a3acf948c43e306fc9a.jpg",
|
||||||
|
map[string]string{":width": "48", ":height": "48", ":ext": "jpg", ":path": "05ac66d9bda00a3acf948c43e306fc9a"}})
|
||||||
routers = append(routers, testinfo{"/v1/shop/:id:int", "/v1/shop/123", map[string]string{":id": "123"}})
|
routers = append(routers, testinfo{"/v1/shop/:id:int", "/v1/shop/123", map[string]string{":id": "123"}})
|
||||||
routers = append(routers, testinfo{"/:year:int/:month:int/:id/:endid", "/1111/111/aaa/aaa", map[string]string{":year": "1111", ":month": "111", ":id": "aaa", ":endid": "aaa"}})
|
routers = append(routers, testinfo{"/:year:int/:month:int/:id/:endid", "/1111/111/aaa/aaa", map[string]string{":year": "1111", ":month": "111", ":id": "aaa", ":endid": "aaa"}})
|
||||||
routers = append(routers, testinfo{"/v1/shop/:id/:name", "/v1/shop/123/nike", map[string]string{":id": "123", ":name": "nike"}})
|
routers = append(routers, testinfo{"/v1/shop/:id/:name", "/v1/shop/123/nike", map[string]string{":id": "123", ":name": "nike"}})
|
||||||
|
Loading…
Reference in New Issue
Block a user