Skip to content

Commit

Permalink
Modified detection charset
Browse files Browse the repository at this point in the history
  • Loading branch information
spiegel-im-spiegel committed Dec 5, 2017
1 parent 92970cf commit 64bc53e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 33 deletions.
24 changes: 9 additions & 15 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
# name = "github.com/x/y"
# version = "2.4.0"

ignored = [
"github.com/cpuguy83/go-md2man/md2man",
"github.com/mitchellh/go-homedir",
"github.com/russross/blackfriday",
"github.com/spf13/cobra/cobra",
"github.com/spf13/cobra/cobra/cmd",
"github.com/spf13/cobra/doc",
"github.com/spf13/viper",
"gopkg.in/yaml.v2",
]

[[constraint]]
name = "github.com/spf13/cobra"
version = "~0.0.1"
Expand All @@ -39,10 +28,6 @@ ignored = [
name = "github.com/spiegel-im-spiegel/gocli"
version = "~0.4.0"

[[constraint]]
name = "github.com/spiegel-im-spiegel/text"
version = "~0.1.0"

[[constraint]]
name = "github.com/pkg/errors"
version = "~0.8.0"
Expand Down
Binary file modified dependency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions mklink.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ func New(url string) (*Link, error) {

br := bufio.NewReader(resp.Body)
var r io.Reader = br
//if data, err2 := br.Peek(1024); err2 == nil { //next 1024 bytes without advancing the reader.
if data, _ := br.Peek(4024); len(data) > 0 { //next 1024 bytes without advancing the reader.
if _, name, ok := charset.DetermineEncoding(data, resp.Header.Get("content-type")); ok {
if data, err2 := br.Peek(1024); err2 == nil { //next 1024 bytes without advancing the reader.
enc, name, _ := charset.DetermineEncoding(data, resp.Header.Get("content-type"))
if enc != nil {
r = enc.NewDecoder().Reader(br)
} else if len(name) > 0 {
if enc := encoding.GetEncoding(name); enc != nil {
r = enc.NewDecoder().Reader(br)
}
Expand Down

0 comments on commit 64bc53e

Please sign in to comment.