mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:20:54 +00:00
improve the empty router
This commit is contained in:
parent
d3ab157915
commit
0c933643e2
3
tree.go
3
tree.go
@ -422,6 +422,9 @@ func (leaf *leafInfo) match(wildcardValues []string) (ok bool, params map[string
|
||||
// "/admin/" -> ["admin"]
|
||||
// "/admin/users" -> ["admin", "users"]
|
||||
func splitPath(key string) []string {
|
||||
if key == "" {
|
||||
return []string{}
|
||||
}
|
||||
elements := strings.Split(key, "/")
|
||||
if elements[0] == "" {
|
||||
elements = elements[1:]
|
||||
|
@ -149,7 +149,11 @@ func TestAddTree2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitPath(t *testing.T) {
|
||||
a := splitPath("/")
|
||||
a := splitPath("")
|
||||
if len(a) != 0 {
|
||||
t.Fatal("/ should retrun []")
|
||||
}
|
||||
a = splitPath("/")
|
||||
if len(a) != 0 {
|
||||
t.Fatal("/ should retrun []")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user