diff --git a/.travis.yml b/.travis.yml index 200f508a..a1fc8768 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,8 @@ go: - 1.12.x - 1.13.x - tip +env: + - GO111MODULE=on install: - go get -v golang.org/x/lint/golint script: diff --git a/echo.go b/echo.go index 5f6671ee..a6ac0fa8 100644 --- a/echo.go +++ b/echo.go @@ -227,7 +227,7 @@ const ( const ( // Version of Echo - Version = "4.1.11" + Version = "4.1.13" website = "https://echo.labstack.com" // http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo banner = ` diff --git a/router.go b/router.go index 8b15e65a..08145973 100644 --- a/router.go +++ b/router.go @@ -412,6 +412,7 @@ func (r *Router) Find(method, path string, c Context) { // Consider param route one level up only // if no slash is remaining in search string if cn = nn.findChildByKind(pkind); cn != nil && strings.IndexByte(ns, '/') == -1 { + pvalues[len(cn.pnames)-1] = search break } for { diff --git a/router_test.go b/router_test.go index cd0817d9..449af910 100644 --- a/router_test.go +++ b/router_test.go @@ -1118,6 +1118,42 @@ func TestRouterMixedParams(t *testing.T) { testRouterAPI(t, api2) } +// Issue #1466 +func TestRouterParam1466(t *testing.T) { + e := New() + r := e.router + + r.Add(http.MethodPost, "/users/signup", func(c Context) error { + return nil + }) + r.Add(http.MethodPost, "/users/signup/bulk", func(c Context) error { + return nil + }) + r.Add(http.MethodPost, "/users/survey", func(c Context) error { + return nil + }) + r.Add(http.MethodGet, "/users/:username", func(c Context) error { + return nil + }) + r.Add(http.MethodGet, "/interests/:name/users", func(c Context) error { + return nil + }) + r.Add(http.MethodGet, "/skills/:name/users", func(c Context) error { + return nil + }) + + c := e.NewContext(nil, nil).(*context) + + r.Find(http.MethodGet, "/users/ajitem", c) + assert.Equal(t, "ajitem", c.Param("username")) + + r.Find(http.MethodGet, "/users/sharewithme", c) + assert.Equal(t, "sharewithme", c.Param("username")) + + r.Find(http.MethodGet, "/users/signup", c) + assert.Equal(t, "", c.Param("username")) +} + func benchmarkRouterRoutes(b *testing.B, routes []*Route) { e := New() r := e.router