Skip to content

Commit

Permalink
Use in-memory input that exposes Bytes()
Browse files Browse the repository at this point in the history
bytes.Reader doesn't provide Bytes but bytes.Buffer does
  • Loading branch information
tdewolff committed Mar 9, 2015
1 parent c412689 commit 69eb7cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions minify.go
Expand Up @@ -160,7 +160,7 @@ func (m DefaultMinifier) Minify(mediatype string, w io.Writer, r io.Reader) erro
func (m DefaultMinifier) MinifyBytes(mediatype string, v []byte) ([]byte, error) {
b := &bytes.Buffer{}
b.Grow(len(v))
if err := m.Minify(mediatype, b, bytes.NewReader(v)); err != nil {
if err := m.Minify(mediatype, b, bytes.NewBuffer(v)); err != nil {
return v, err
}
return b.Bytes(), nil
Expand All @@ -171,7 +171,7 @@ func (m DefaultMinifier) MinifyBytes(mediatype string, v []byte) ([]byte, error)
func (m DefaultMinifier) MinifyString(mediatype string, v string) (string, error) {
b := &bytes.Buffer{}
b.Grow(len(v))
if err := m.Minify(mediatype, b, bytes.NewReader([]byte(v))); err != nil {
if err := m.Minify(mediatype, b, bytes.NewBufferString(v)); err != nil {
return v, err
}
return b.String(), nil
Expand Down

0 comments on commit 69eb7cf

Please sign in to comment.