diff options
Diffstat (limited to 'brokenlinks/worker.go')
| -rw-r--r-- | brokenlinks/worker.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/brokenlinks/worker.go b/brokenlinks/worker.go index 09c8b12..3e089fc 100644 --- a/brokenlinks/worker.go +++ b/brokenlinks/worker.go @@ -266,14 +266,18 @@ func (wrk *worker) scan(linkq jarink.Link) (resultq map[string]jarink.Link) { return resultq } - // After we check the code for [html.Parse] there are no cases where - // it will return an error. - // The only possible error is when reading from body (io.Reader), and - // that is also almost impossible. - // - // [html.Parse]: https://go.googlesource.com/net/+/refs/tags/v0.40.0/html/parse.go#2347 + contentType := httpResp.Header.Get(`Content-Type`) + if !strings.HasPrefix(contentType, `text/html`) { + return resultq + } + var doc *html.Node - doc, _ = html.Parse(httpResp.Body) + doc, err = html.Parse(httpResp.Body) + if err != nil { + linkq.ErrScan = err + resultq[linkq.Url] = linkq + return resultq + } var parentUrl *url.URL |
