mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Return an empty string for ctx.path if there is no registered path
This commit is contained in:
parent
24a30611df
commit
08093a4a1d
@ -524,7 +524,6 @@ func optionsMethodHandler(allowMethods string) func(c Context) error {
|
||||
// - Return it `Echo#ReleaseContext()`.
|
||||
func (r *Router) Find(method, path string, c Context) {
|
||||
ctx := c.(*context)
|
||||
ctx.path = path
|
||||
currentNode := r.tree // Current node as root
|
||||
|
||||
var (
|
||||
|
@ -674,6 +674,18 @@ func TestRouterStatic(t *testing.T) {
|
||||
assert.Equal(t, path, c.Get("path"))
|
||||
}
|
||||
|
||||
func TestRouterNoRoutablePath(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
|
||||
r.Find(http.MethodGet, "/notfound", c)
|
||||
c.handler(c)
|
||||
|
||||
// No routable path, don't set Path.
|
||||
assert.Equal(t, "", c.Path())
|
||||
}
|
||||
|
||||
func TestRouterParam(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
|
Loading…
Reference in New Issue
Block a user