Skip to content

Commit 08093a4

Browse files
brietayloraldas
authored andcommitted
Return an empty string for ctx.path if there is no registered path
1 parent 24a3061 commit 08093a4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

router.go

-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ func optionsMethodHandler(allowMethods string) func(c Context) error {
524524
// - Return it `Echo#ReleaseContext()`.
525525
func (r *Router) Find(method, path string, c Context) {
526526
ctx := c.(*context)
527-
ctx.path = path
528527
currentNode := r.tree // Current node as root
529528

530529
var (

router_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,18 @@ func TestRouterStatic(t *testing.T) {
674674
assert.Equal(t, path, c.Get("path"))
675675
}
676676

677+
func TestRouterNoRoutablePath(t *testing.T) {
678+
e := New()
679+
r := e.router
680+
c := e.NewContext(nil, nil).(*context)
681+
682+
r.Find(http.MethodGet, "/notfound", c)
683+
c.handler(c)
684+
685+
// No routable path, don't set Path.
686+
assert.Equal(t, "", c.Path())
687+
}
688+
677689
func TestRouterParam(t *testing.T) {
678690
e := New()
679691
r := e.router

0 commit comments

Comments
 (0)