mirror of
https://github.com/labstack/echo.git
synced 2025-11-25 22:32:23 +02:00
When route is registered with empty path it is normalized to /. Make sure that returned echo.Route structs reflect that behavior. (#2616)
This commit is contained in:
@@ -2770,6 +2770,22 @@ func TestRouter_Routes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRouter_addEmptyPathToSlashReverse(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
r.add(http.MethodGet, "", "empty", handlerFunc) // emtpy path is normalized to `/`
|
||||
|
||||
assert.Equal(t, "/", r.Reverse("empty"))
|
||||
}
|
||||
|
||||
func TestRouter_ReverseNotFound(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
r.add(http.MethodGet, "", "empty", handlerFunc)
|
||||
|
||||
assert.Equal(t, "", r.Reverse("not-existing"))
|
||||
}
|
||||
|
||||
func TestRouter_Reverse(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
|
||||
Reference in New Issue
Block a user