Commit 0c933643 authored by astaxie's avatar astaxie

improve the empty router

parent d3ab1579
......@@ -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 []")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment