mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Fixed double padding in Group.File, Group.Add (#1534)
Group.File was padding with g.prefix even though it would later call Group.Add which padded with prefix again - for a total of two times
This commit is contained in:
parent
2207c37bf8
commit
c29904d81c
2
group.go
2
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.
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user