Commit ae52d4aa authored by astaxie's avatar astaxie

improve the splitPath

parent e5096be3
......@@ -354,10 +354,22 @@ func (t *Tree) match(pattern string, wildcardValues []string, ctx *context.Conte
}
if runObject == nil {
segments := splitPath(pattern)
wildcardValues = append(wildcardValues, seg)
start, i := 0, 0
for ; i < len(pattern); i++ {
if pattern[i] == '/' {
if i != 0 && start < len(pattern) {
wildcardValues = append(wildcardValues, pattern[start:i])
}
start = i + 1
continue
}
}
if start > 0 {
wildcardValues = append(wildcardValues, pattern[start:i])
}
for _, l := range t.leaves {
if ok := l.match(append(wildcardValues, segments...), ctx); ok {
if ok := l.match(wildcardValues, ctx); ok {
return l.runObject
}
}
......
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