mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:00:55 +00:00
beego: fix the addTree
This commit is contained in:
parent
52fdfc5665
commit
f201859fa7
16
tree.go
16
tree.go
@ -108,9 +108,13 @@ func (t *Tree) addtree(segments []string, tree *Tree, wildcards []string, reg st
|
||||
if w == "." || w == ":" {
|
||||
continue
|
||||
}
|
||||
if w == ":splat" {
|
||||
regexpStr = "/(.+)" + regexpStr
|
||||
} else {
|
||||
regexpStr = "/([^/]+)" + regexpStr
|
||||
}
|
||||
}
|
||||
}
|
||||
reg = reg + regexpStr
|
||||
t.wildcard.addtree(segments[1:], tree, append(wildcards, params...), reg)
|
||||
} else {
|
||||
@ -145,20 +149,16 @@ func filterTreeWithPrefix(t *Tree, wildcards []string, reg string) {
|
||||
}
|
||||
} else {
|
||||
if l.regexps != nil {
|
||||
filterCards := []string{}
|
||||
for _, v := range l.wildcards {
|
||||
if v == ":" || v == "." {
|
||||
continue
|
||||
}
|
||||
filterCards = append(filterCards, v)
|
||||
}
|
||||
l.wildcards = filterCards
|
||||
for _, w := range wildcards {
|
||||
if w == "." || w == ":" {
|
||||
continue
|
||||
}
|
||||
if w == ":splat" {
|
||||
reg = "(.+)/" + reg
|
||||
} else {
|
||||
reg = "([^/]+)/" + reg
|
||||
}
|
||||
}
|
||||
l.regexps = regexp.MustCompile("^" + reg + strings.Trim(l.regexps.String(), "^$") + "$")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user