Update tree.go

This commit is contained in:
田欧 2019-02-20 16:28:19 +08:00 committed by GitHub
parent 028cb5508f
commit f73e1ea630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

24
tree.go
View File

@ -192,19 +192,19 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
if len(n.path) >= len(path) || path[len(n.path)] == '/' { if len(n.path) >= len(path) || path[len(n.path)] == '/' {
continue walk continue walk
} }
} else {
// Wildcard conflict
pathSeg := path
if n.nType != catchAll {
pathSeg = strings.SplitN(path, "/", 2)[0]
}
prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path
panic("'" + pathSeg +
"' in new path '" + fullPath +
"' conflicts with existing wildcard '" + n.path +
"' in existing prefix '" + prefix +
"'")
} }
// Wildcard conflict
pathSeg := path
if n.nType != catchAll {
pathSeg = strings.SplitN(path, "/", 2)[0]
}
prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path
panic("'" + pathSeg +
"' in new path '" + fullPath +
"' conflicts with existing wildcard '" + n.path +
"' in existing prefix '" + prefix +
"'")
} }
c := path[0] c := path[0]