beego: fix the addTree
Showing
1 changed file
with
10 additions
and
10 deletions
| ... | @@ -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 |
| 108 | if w == "." || w == ":" { | 108 | if w == "." || w == ":" { |
| 109 | continue | 109 | continue |
| 110 | } | 110 | } |
| 111 | regexpStr = "/([^/]+)" + regexpStr | 111 | if w == ":splat" { |
| 112 | regexpStr = "/(.+)" + regexpStr | ||
| 113 | } else { | ||
| 114 | regexpStr = "/([^/]+)" + regexpStr | ||
| 115 | } | ||
| 112 | } | 116 | } |
| 113 | } | 117 | } |
| 114 | reg = reg + regexpStr | 118 | 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) { |
| 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 | } |
| 160 | reg = "([^/]+)/" + reg | 156 | if w == ":splat" { |
| 157 | reg = "(.+)/" + reg | ||
| 158 | } else { | ||
| 159 | reg = "([^/]+)/" + reg | ||
| 160 | } | ||
| 161 | } | 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 | } | ... | ... |
-
Please register or sign in to post a comment