simplify the implementation of splitPath in tree.go

This commit is contained in:
youngsterxyf 2016-01-18 16:13:31 +08:00
parent ac3b013de7
commit 30e5634bdb
1 changed files with 2 additions and 8 deletions

10
tree.go
View File

@ -448,17 +448,11 @@ func (leaf *leafInfo) match(wildcardValues []string, ctx *context.Context) (ok b
// "/admin/" -> ["admin"]
// "/admin/users" -> ["admin", "users"]
func splitPath(key string) []string {
key = strings.Trim(key, "/ ")
if key == "" {
return []string{}
}
elements := strings.Split(key, "/")
if elements[0] == "" {
elements = elements[1:]
}
if elements[len(elements)-1] == "" {
elements = elements[:len(elements)-1]
}
return elements
return strings.Split(key, "/")
}
// "admin" -> false, nil, ""