Skip to content

Commit

Permalink
Merge branch 'meehow-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
vishr committed Jul 18, 2019
2 parents 9bf857f + 207a141 commit 405b221
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
13 changes: 7 additions & 6 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type (
pnames []string
methodHandler *methodHandler
}
kind uint8
children []*node
kind uint8
children []*node
methodHandler struct {
connect HandlerFunc
delete HandlerFunc
Expand Down Expand Up @@ -336,19 +336,21 @@ 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 {
goto Param
} else if nk == akind {
goto Any
}
// Not found
return
}

if search == "" {
Expand Down Expand Up @@ -405,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
Expand Down
12 changes: 12 additions & 0 deletions router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 405b221

Please sign in to comment.