mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
fix readability edge case
This commit is contained in:
parent
56e5625adc
commit
e62906e63d
@ -6,6 +6,7 @@
|
|||||||
- (fix) favicon visibility in dark mode (thanks to @caycaycarly for the report)
|
- (fix) favicon visibility in dark mode (thanks to @caycaycarly for the report)
|
||||||
- (fix) autoloading more articles not working in certain edge cases (thanks to @fenuks for the report)
|
- (fix) autoloading more articles not working in certain edge cases (thanks to @fenuks for the report)
|
||||||
- (fix) handle Google URL redirects in "Read Here" (thanks to @cubbei for discovery)
|
- (fix) handle Google URL redirects in "Read Here" (thanks to @cubbei for discovery)
|
||||||
|
- (fix) handle failures to extract content in "Read Here" (thanks to @grigio for the report)
|
||||||
|
|
||||||
# v2.3 (2022-05-03)
|
# v2.3 (2022-05-03)
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ package readability
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
@ -59,6 +60,9 @@ func ExtractContent(page io.Reader) (string, error) {
|
|||||||
best = body
|
best = body
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if best == nil {
|
||||||
|
return "", errors.New("failed to extract content")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//log.Printf("[Readability] TopCandidate: %v", topCandidate)
|
//log.Printf("[Readability] TopCandidate: %v", topCandidate)
|
||||||
|
|
||||||
|
@ -474,8 +474,9 @@ func (s *Server) handlePageCrawl(c *router.Context) {
|
|||||||
}
|
}
|
||||||
content, err := readability.ExtractContent(strings.NewReader(body))
|
content, err := readability.ExtractContent(strings.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
c.JSON(http.StatusOK, map[string]string{
|
||||||
c.Out.WriteHeader(http.StatusNoContent)
|
"content": "error: " + err.Error(),
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
content = sanitizer.Sanitize(url, content)
|
content = sanitizer.Sanitize(url, content)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user