Skip to content

Commit

Permalink
Merge pull request #42 from aliras1/master
Browse files Browse the repository at this point in the history
Made Content-Type check whitespace agnostic in LoadURL()
  • Loading branch information
magiconair committed Aug 6, 2020
2 parents cfba716 + cc04d6f commit ff39abe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions load.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ func (l *Loader) LoadURL(url string) (*Properties, error) {
}

ct := resp.Header.Get("Content-Type")
ct = strings.Join(strings.Fields(ct), "")
var enc Encoding
switch strings.ToLower(ct) {
case "text/plain", "text/plain; charset=iso-8859-1", "text/plain; charset=latin1":
case "text/plain", "text/plain;charset=iso-8859-1", "text/plain;charset=latin1":
enc = ISO_8859_1
case "", "text/plain; charset=utf-8":
case "", "text/plain;charset=utf-8":
enc = UTF8
default:
return nil, fmt.Errorf("properties: invalid content type %s", ct)
Expand Down

0 comments on commit ff39abe

Please sign in to comment.