mirror of
https://github.com/labstack/echo.git
synced 2025-07-15 01:34:53 +02:00
Fix router not matching param route with trailing slash and implement matching by path+method (#1812)
* when url ends with slash first param route is the match (fix #1804) * router should check if method is suitable for matching route and if not then continue search in tree (fix #1808)
This commit is contained in:
@ -464,7 +464,9 @@ func TestContextPath(t *testing.T) {
|
||||
e := New()
|
||||
r := e.Router()
|
||||
|
||||
r.Add(http.MethodGet, "/users/:id", nil)
|
||||
handler := func(c Context) error { return c.String(http.StatusOK, "OK") }
|
||||
|
||||
r.Add(http.MethodGet, "/users/:id", handler)
|
||||
c := e.NewContext(nil, nil)
|
||||
r.Find(http.MethodGet, "/users/1", c)
|
||||
|
||||
@ -472,7 +474,7 @@ func TestContextPath(t *testing.T) {
|
||||
|
||||
assert.Equal("/users/:id", c.Path())
|
||||
|
||||
r.Add(http.MethodGet, "/users/:uid/files/:fid", nil)
|
||||
r.Add(http.MethodGet, "/users/:uid/files/:fid", handler)
|
||||
c = e.NewContext(nil, nil)
|
||||
r.Find(http.MethodGet, "/users/1/files/1", c)
|
||||
assert.Equal("/users/:uid/files/:fid", c.Path())
|
||||
|
Reference in New Issue
Block a user