1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 03:10:50 +00:00

beego: fix the addTree

This commit is contained in:
astaxie 2014-08-12 00:15:39 +08:00
parent 52fdfc5665
commit f201859fa7

20
tree.go
View File

@ -108,7 +108,11 @@ func (t *Tree) addtree(segments []string, tree *Tree, wildcards []string, reg st
if w == "." || w == ":" {
continue
}
regexpStr = "/([^/]+)" + regexpStr
if w == ":splat" {
regexpStr = "/(.+)" + regexpStr
} else {
regexpStr = "/([^/]+)" + regexpStr
}
}
}
reg = reg + regexpStr
@ -145,19 +149,15 @@ 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
}
reg = "([^/]+)/" + reg
if w == ":splat" {
reg = "(.+)/" + reg
} else {
reg = "([^/]+)/" + reg
}
}
l.regexps = regexp.MustCompile("^" + reg + strings.Trim(l.regexps.String(), "^$") + "$")
}