f201859f by astaxie

beego: fix the addTree

1 parent 52fdfc56
Showing 1 changed file with 8 additions and 8 deletions
...@@ -108,9 +108,13 @@ func (t *Tree) addtree(segments []string, tree *Tree, wildcards []string, reg st ...@@ -108,9 +108,13 @@ func (t *Tree) addtree(segments []string, tree *Tree, wildcards []string, reg st
108 if w == "." || w == ":" { 108 if w == "." || w == ":" {
109 continue 109 continue
110 } 110 }
111 if w == ":splat" {
112 regexpStr = "/(.+)" + regexpStr
113 } else {
111 regexpStr = "/([^/]+)" + regexpStr 114 regexpStr = "/([^/]+)" + regexpStr
112 } 115 }
113 } 116 }
117 }
114 reg = reg + regexpStr 118 reg = reg + regexpStr
115 t.wildcard.addtree(segments[1:], tree, append(wildcards, params...), reg) 119 t.wildcard.addtree(segments[1:], tree, append(wildcards, params...), reg)
116 } else { 120 } else {
...@@ -145,20 +149,16 @@ func filterTreeWithPrefix(t *Tree, wildcards []string, reg string) { ...@@ -145,20 +149,16 @@ func filterTreeWithPrefix(t *Tree, wildcards []string, reg string) {
145 } 149 }
146 } else { 150 } else {
147 if l.regexps != nil { 151 if l.regexps != nil {
148 filterCards := []string{}
149 for _, v := range l.wildcards {
150 if v == ":" || v == "." {
151 continue
152 }
153 filterCards = append(filterCards, v)
154 }
155 l.wildcards = filterCards
156 for _, w := range wildcards { 152 for _, w := range wildcards {
157 if w == "." || w == ":" { 153 if w == "." || w == ":" {
158 continue 154 continue
159 } 155 }
156 if w == ":splat" {
157 reg = "(.+)/" + reg
158 } else {
160 reg = "([^/]+)/" + reg 159 reg = "([^/]+)/" + reg
161 } 160 }
161 }
162 l.regexps = regexp.MustCompile("^" + reg + strings.Trim(l.regexps.String(), "^$") + "$") 162 l.regexps = regexp.MustCompile("^" + reg + strings.Trim(l.regexps.String(), "^$") + "$")
163 } 163 }
164 } 164 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!