Apply hepa filters before gzip'ing content

- markbates/pkger#26
This commit is contained in:
Neil Skinner 2020-06-03 12:46:06 -04:00
parent d97c60c346
commit fdcec3a4ea
1 changed files with 10 additions and 10 deletions

View File

@ -31,6 +31,15 @@ func Decode(src []byte) ([]byte, error) {
} }
func Encode(b []byte) ([]byte, error) { func Encode(b []byte) ([]byte, error) {
hep := hepa.New()
hep = hepa.With(hep, filters.Home())
hep = hepa.With(hep, filters.Golang())
b, err := hep.Filter(b)
if err != nil {
return nil, err
}
bb := &bytes.Buffer{} bb := &bytes.Buffer{}
gz := gzip.NewWriter(bb) gz := gzip.NewWriter(bb)
@ -46,16 +55,7 @@ func Encode(b []byte) ([]byte, error) {
return nil, err return nil, err
} }
hep := hepa.New() s := hex.EncodeToString(bb.Bytes())
hep = hepa.With(hep, filters.Home())
hep = hepa.With(hep, filters.Golang())
b, err := hep.Filter(bb.Bytes())
if err != nil {
return nil, err
}
s := hex.EncodeToString(b)
return []byte(s), nil return []byte(s), nil
} }