1
0
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:
Martti T
2024-03-27 12:28:46 +02:00
committed by GitHub
parent d549290448
commit 447c92d842
3 changed files with 44 additions and 15 deletions

View File

@@ -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