diff --git a/group.go b/group.go index 5d958253..426bef9e 100644 --- a/group.go +++ b/group.go @@ -109,7 +109,7 @@ func (g *Group) Static(prefix, root string) { // File implements `Echo#File()` for sub-routes within the Group. func (g *Group) File(path, file string) { - g.file(g.prefix+path, file, g.GET) + g.file(path, file, g.GET) } // Add implements `Echo#Add()` for sub-routes within the Group. diff --git a/group_test.go b/group_test.go index 342cd29e..c51fd91e 100644 --- a/group_test.go +++ b/group_test.go @@ -1,7 +1,9 @@ package echo import ( + "io/ioutil" "net/http" + "net/http/httptest" "testing" "github.com/stretchr/testify/assert" @@ -26,6 +28,19 @@ func TestGroup(t *testing.T) { g.File("/walle", "_fixture/images//walle.png") } +func TestGroupFile(t *testing.T) { + e := New() + g := e.Group("/group") + g.File("/walle", "_fixture/images/walle.png") + expectedData, err := ioutil.ReadFile("_fixture/images/walle.png") + assert.Nil(t, err) + req := httptest.NewRequest(http.MethodGet, "/group/walle", nil) + rec := httptest.NewRecorder() + e.ServeHTTP(rec, req) + assert.Equal(t, http.StatusOK, rec.Code) + assert.Equal(t, expectedData, rec.Body.Bytes()) +} + func TestGroupRouteMiddleware(t *testing.T) { // Ensure middleware slices are not re-used e := New()