Commit f201859f authored by astaxie's avatar astaxie

beego: fix the addTree

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