summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--href.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/href.go b/href.go
index 2c4d915..3135840 100644
--- a/href.go
+++ b/href.go
@@ -6,11 +6,13 @@ import (
"strings"
"golang.org/x/net/html"
+ "golang.org/x/net/html/charset"
)
var (
- notHTML = errors.New("not HTML content")
- tooBig = errors.New("cotent too big")
+ notHTML = errors.New("not HTML content")
+ tooBig = errors.New("cotent too big")
+ iconvErr = errors.New("charset converter error")
)
const (
@@ -49,7 +51,12 @@ func FetchTitle(url string) (string, error) {
return "", tooBig
}
- doc, err := html.Parse(resp.Body)
+ r, err := charset.NewReader(resp.Body, ct)
+ if err != nil {
+ return "", iconvErr
+ }
+
+ doc, err := html.Parse(r)
if err != nil {
return "", err
}