Skip to content

Commit 4c4b493

Browse files
committed
Return an empty string for ctx.path if there is no registered path
1 parent 24a3061 commit 4c4b493

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

router.go

Lines changed: 0 additions & 1 deletion
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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,19 @@ 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+
request_path := "/notfound"
681+
c := e.NewContext(nil, nil).(*context)
682+
683+
r.Find(http.MethodGet, request_path, c)
684+
c.handler(c)
685+
686+
// No routable path, don't set Path.
687+
assert.Equal(t, "", c.Path())
688+
}
689+
677690
func TestRouterParam(t *testing.T) {
678691
e := New()
679692
r := e.router

0 commit comments

Comments
 (0)