mirror of
https://github.com/labstack/echo.git
synced 2024-11-24 08:22:21 +02:00
parent
ae55310e59
commit
207a141d5d
16
router.go
16
router.go
@ -20,8 +20,8 @@ type (
|
||||
pnames []string
|
||||
methodHandler *methodHandler
|
||||
}
|
||||
kind uint8
|
||||
children []*node
|
||||
kind uint8
|
||||
children []*node
|
||||
methodHandler struct {
|
||||
connect HandlerFunc
|
||||
delete HandlerFunc
|
||||
@ -218,9 +218,6 @@ func (n *node) findChildWithLabel(l byte) *node {
|
||||
}
|
||||
|
||||
func (n *node) findChildByKind(t kind) *node {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
for _, c := range n.children {
|
||||
if c.kind == t {
|
||||
return c
|
||||
@ -339,10 +336,14 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if l == pl {
|
||||
// Continue search
|
||||
search = search[l:]
|
||||
} else {
|
||||
if nn == nil { // Issue #1348
|
||||
return // Not found
|
||||
}
|
||||
cn = nn
|
||||
search = ns
|
||||
if nk == pkind {
|
||||
@ -350,8 +351,6 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
} else if nk == akind {
|
||||
goto Any
|
||||
}
|
||||
// Not found
|
||||
return
|
||||
}
|
||||
|
||||
if search == "" {
|
||||
@ -408,8 +407,7 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
goto Any
|
||||
}
|
||||
}
|
||||
// Not found
|
||||
return
|
||||
return // Not found
|
||||
}
|
||||
pvalues[len(cn.pnames)-1] = search
|
||||
break
|
||||
|
@ -741,6 +741,18 @@ func TestRouterPriority(t *testing.T) {
|
||||
assert.Equal(t, "joe/books", c.Param("*"))
|
||||
}
|
||||
|
||||
func TestRouterIssue1348(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
|
||||
r.Add(http.MethodGet, "/:lang/", func(c Context) error {
|
||||
return nil
|
||||
})
|
||||
r.Add(http.MethodGet, "/:lang/dupa", func(c Context) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Issue #372
|
||||
func TestRouterPriorityNotFound(t *testing.T) {
|
||||
e := New()
|
||||
@ -756,12 +768,6 @@ func TestRouterPriorityNotFound(t *testing.T) {
|
||||
c.Set("b", 2)
|
||||
return nil
|
||||
})
|
||||
r.Add(http.MethodGet, "/:lang/", func(c Context) error {
|
||||
return nil
|
||||
})
|
||||
r.Add(http.MethodGet, "/:lang/dupa", func(c Context) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
// Find
|
||||
r.Find(http.MethodGet, "/a/foo", c)
|
||||
|
Loading…
Reference in New Issue
Block a user