1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 20:00:50 +00:00

improve the empty router

This commit is contained in:
astaxie 2014-12-19 15:33:51 +08:00
parent d3ab157915
commit 0c933643e2
2 changed files with 8 additions and 1 deletions

View File

@ -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:]

View File

@ -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 []")
}