Skip to content

Commit 97d7376

Browse files
author
zhangmj
committed
Merge branch 'master' into mymaster
2 parents 8a84480 + 9f598a3 commit 97d7376

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tree.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ func (n *node) insertChild(path string, fullPath string, handlers HandlersChain)
351351
}
352352

353353
if len(n.path) > 0 && n.path[len(n.path)-1] == '/' {
354-
pathSeg := strings.SplitN(n.children[0].path, "/", 2)[0]
354+
pathSeg := ""
355+
if len(n.children) != 0 {
356+
pathSeg = strings.SplitN(n.children[0].path, "/", 2)[0]
357+
}
355358
panic("catch-all wildcard '" + path +
356359
"' in new path '" + fullPath +
357360
"' conflicts with existing path segment '" + pathSeg +

tree_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ func TestTreeWildcardConflict(t *testing.T) {
417417
{"/user_:name", false},
418418
{"/id:id", false},
419419
{"/id/:id", false},
420+
{"/static/*file", false},
421+
{"/static/", true},
420422
}
421423
testRoutes(t, routes)
422424
}

0 commit comments

Comments
 (0)