diff --git a/routes_test.go b/routes_test.go index 036fa1c349..380ed1b983 100644 --- a/routes_test.go +++ b/routes_test.go @@ -621,3 +621,24 @@ func TestRouteContextHoldsFullPath(t *testing.T) { w := performRequest(router, http.MethodGet, "/not-found") assert.Equal(t, http.StatusNotFound, w.Code) } + +// Reproduction test for the bug of issue #2843 +func TestRouteTrailingSlashRoute(t *testing.T) { + router := New() + + router.NoRoute(func(c *Context) { + if c.Request.RequestURI == "/login" { + c.String(200, "login") + } + }) + + router.GET("/logout", func(c *Context) { + c.String(200, "logout") + }) + + w := performRequest(router, http.MethodGet, "/login") + assert.Equal(t, "login", w.Body.String()) + + w = performRequest(router, http.MethodGet, "/logout") + assert.Equal(t, "logout", w.Body.String()) +}