1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-16 02:42:16 +00:00

Merge pull request #1615 from ysqi/routerErrorFix

Fixed #1586
This commit is contained in:
astaxie
2016-01-26 00:31:01 +08:00
2 changed files with 40 additions and 45 deletions

14
tree.go
View File

@@ -442,7 +442,9 @@ func (leaf *leafInfo) match(wildcardValues []string, ctx *context.Context) (ok b
}
matches := leaf.regexps.FindStringSubmatch(path.Join(wildcardValues...))
for i, match := range matches[1:] {
ctx.Input.SetParam(leaf.wildcards[i], match)
if i < len(leaf.wildcards) {
ctx.Input.SetParam(leaf.wildcards[i], match)
}
}
return true
}
@@ -540,13 +542,19 @@ func splitSegment(key string) (bool, []string, string) {
continue
}
}
if v == ':' {
// Escape Sequence '\'
if i > 0 && key[i-1] == '\\' {
out = append(out, v)
} else if v == ':' {
param = make([]rune, 0)
start = true
} else if v == '(' {
startexp = true
start = false
params = append(params, ":"+string(param))
if len(param) > 0 {
params = append(params, ":"+string(param))
param = make([]rune, 0)
}
paramsNum++
expt = make([]rune, 0)
expt = append(expt, '(')