mirror of
https://github.com/labstack/echo.git
synced 2025-07-03 00:56:59 +02:00
@ -356,6 +356,11 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
|||||||
// Param node
|
// Param node
|
||||||
Param:
|
Param:
|
||||||
if c = cn.findChildByKind(pkind); c != nil {
|
if c = cn.findChildByKind(pkind); c != nil {
|
||||||
|
// Issue #378
|
||||||
|
if len(ctx.pvalues) == n {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Save next
|
// Save next
|
||||||
if cn.label == '/' {
|
if cn.label == '/' {
|
||||||
nk = akind
|
nk = akind
|
||||||
@ -363,6 +368,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
|||||||
ns = search
|
ns = search
|
||||||
}
|
}
|
||||||
cn = c
|
cn = c
|
||||||
|
|
||||||
i, l := 0, len(search)
|
i, l := 0, len(search)
|
||||||
for ; i < l && search[i] != '/'; i++ {
|
for ; i < l && search[i] != '/'; i++ {
|
||||||
}
|
}
|
||||||
|
@ -311,6 +311,25 @@ func TestRouterTwoParam(t *testing.T) {
|
|||||||
assert.Equal(t, "1", c.P(1))
|
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) {
|
func TestRouterMatchAny(t *testing.T) {
|
||||||
e := New()
|
e := New()
|
||||||
r := e.router
|
r := e.router
|
||||||
|
Reference in New Issue
Block a user