Commit deb07539 authored by Simao Gomes Viana's avatar Simao Gomes Viana 🛠
Browse files

Fixes

parent 2e54180c
......@@ -20,6 +20,7 @@ require (
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/miekg/dns v1.1.35 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.8.0 // indirect
github.com/smallstep/certificates v0.15.5 // indirect
github.com/smallstep/nosql v0.3.2 // indirect
......
......@@ -89,10 +89,11 @@ func (i *InjectedWriter) Write(bytes []byte) (int, error) {
i.contentTypeStatus = noMatch
return i.originalWriter.Write(bytes)
}
i.contentTypeStatus = matches
i.recordedHtml.Write(bytes)
recordedString := i.recordedHtml.String()
i.recordedHtml.Truncate(0)
if strings.ContainsRune(recordedString, '\n') {
i.recordedHtml.Truncate(0)
isLastLineComplete := false
if strings.HasSuffix(recordedString, "\n") {
isLastLineComplete = true
......@@ -176,6 +177,9 @@ func (m Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddy
logger: m.logger,
m: &m,
}
if len(m.ContentType) == 0 {
injectedWriter.contentTypeStatus = matches
}
err := next.ServeHTTP(injectedWriter, r)
if err != nil {
return err
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment