Skip to content

Added fix for instance of Echo that have a prefix (created with `Group()... #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (e *Echo) URI(h Handler, params ...string) string {
}
}
}
return uri.String()
return e.prefix + uri.String()
}

// URL is an alias for URI
Expand Down
18 changes: 18 additions & 0 deletions echo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,16 @@ func TestEchoURL(t *testing.T) {
static := func(*Context) {}
getUser := func(*Context) {}
getFile := func(*Context) {}
getGroups := func(*Context) {}
getGroup := func(*Context) {}

e.Get("/static/file", static)
e.Get("/users/:id", getUser)
e.Get("/users/:uid/files/:fid", getFile)

eg := e.Group("/groups")
eg.Get("/:id", getGroup)

if e.URL(static) != "/static/file" {
t.Error("uri should be /static/file")
}
Expand All @@ -261,6 +267,18 @@ func TestEchoURL(t *testing.T) {
if e.URI(getFile, "1", "1") != "/users/1/files/1" {
t.Error("uri should be /users/1/files/1")
}
if e.URI(getGroups) != "/groups" {
t.Error("uri should be /groups")
}
if e.URI(getGroup, "1") != "/groups/1" {
t.Error("uri should be /groups/1")
}
if eg.URI(getGroups) != "/groups" {
t.Error("uri should be /groups")
}
if eg.URI(getGroup, "1") != "/groups/1" {
t.Error("uri should be /groups/1")
}
}

func TestEchoNotFound(t *testing.T) {
Expand Down