diff --git a/router.go b/router.go index 9da3cee3..644eceec 100644 --- a/router.go +++ b/router.go @@ -356,6 +356,11 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo // Param node Param: if c = cn.findChildByKind(pkind); c != nil { + // Issue #378 + if len(ctx.pvalues) == n { + continue + } + // Save next if cn.label == '/' { nk = akind @@ -363,6 +368,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo ns = search } cn = c + i, l := 0, len(search) for ; i < l && search[i] != '/'; i++ { } diff --git a/router_test.go b/router_test.go index 2750198e..867a32cf 100644 --- a/router_test.go +++ b/router_test.go @@ -311,6 +311,25 @@ func TestRouterTwoParam(t *testing.T) { assert.Equal(t, "1", c.P(1)) } +// Issue #378 +func TestRouterParamWithSlash(t *testing.T) { + e := New() + r := e.router + + r.Add(GET, "/a/:b/c/d/:e", func(c *Context) error { + return nil + }, e) + + r.Add(GET, "/a/:b/c/:d/:f", func(c *Context) error { + return nil + }, e) + + c := NewContext(nil, nil, e) + assert.NotPanics(t, func() { + r.Find(GET, "/a/1/c/d/2/3", c) + }) +} + func TestRouterMatchAny(t *testing.T) { e := New() r := e.router