1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 18:30:56 +00:00

Merge pull request #2124 from astaxie/revert-2071-issue_accept_encoding

Revert "route variables should not have underline"
This commit is contained in:
astaxie 2016-08-29 13:42:53 +08:00 committed by GitHub
commit bb860d2752
2 changed files with 2 additions and 4 deletions

View File

@ -467,7 +467,7 @@ func splitPath(key string) []string {
// ":name:string" -> true, [:name], ([\w]+)
// ":id([0-9]+)" -> true, [:id], ([0-9]+)
// ":id([0-9]+)_:name" -> true, [:id :name], ([0-9]+)_(.+)
// "cms_:id_:page.html" -> true, [:id :page], cms_(.+)_(.+).html
// "cms_:id_:page.html" -> true, [:id_ :page], cms_(.+)(.+).html
// "cms_:id(.+)_:page.html" -> true, [:id :page], cms_(.+)_(.+).html
// "*" -> true, [:splat], ""
// "*.*" -> true,[. :path :ext], "" . meaning separator
@ -487,7 +487,7 @@ func splitSegment(key string) (bool, []string, string) {
var expt []rune
var skipnum int
params := []string{}
reg := regexp.MustCompile(`[a-zA-Z0-9]+`)
reg := regexp.MustCompile(`[a-zA-Z0-9_]+`)
for i, v := range key {
if skipnum > 0 {
skipnum--

View File

@ -74,8 +74,6 @@ func init() {
routers = append(routers, testinfo{"/v1/:v(.+)_cms/ttt_:id(.+)_:page(.+).html", "/v1/2_cms/ttt_123_1.html", map[string]string{":v": "2", ":id": "123", ":page": "1"}})
routers = append(routers, testinfo{"/api/projects/:pid/members/?:mid", "/api/projects/1/members", map[string]string{":pid": "1"}})
routers = append(routers, testinfo{"/api/projects/:pid/members/?:mid", "/api/projects/1/members/2", map[string]string{":pid": "1", ":mid": "2"}})
routers = append(routers, testinfo{"/view/:id_:page", "/view/12_33", map[string]string{":id": "12", ":page": "33"}})
routers = append(routers, testinfo{"/view/:id_:page.html", "/view/12_33.html", map[string]string{":id": "12", ":page": "33"}})
}
func TestTreeRouters(t *testing.T) {