mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 18:00:55 +00:00
simplify the implementation of splitPath in tree.go
This commit is contained in:
parent
ac3b013de7
commit
30e5634bdb
10
tree.go
10
tree.go
@ -448,17 +448,11 @@ func (leaf *leafInfo) match(wildcardValues []string, ctx *context.Context) (ok b
|
|||||||
// "/admin/" -> ["admin"]
|
// "/admin/" -> ["admin"]
|
||||||
// "/admin/users" -> ["admin", "users"]
|
// "/admin/users" -> ["admin", "users"]
|
||||||
func splitPath(key string) []string {
|
func splitPath(key string) []string {
|
||||||
|
key = strings.Trim(key, "/ ")
|
||||||
if key == "" {
|
if key == "" {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
elements := strings.Split(key, "/")
|
return strings.Split(key, "/")
|
||||||
if elements[0] == "" {
|
|
||||||
elements = elements[1:]
|
|
||||||
}
|
|
||||||
if elements[len(elements)-1] == "" {
|
|
||||||
elements = elements[:len(elements)-1]
|
|
||||||
}
|
|
||||||
return elements
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// "admin" -> false, nil, ""
|
// "admin" -> false, nil, ""
|
||||||
|
Loading…
Reference in New Issue
Block a user