Skip to content

Commit

Permalink
respect charset within readBlobAsText
Browse files Browse the repository at this point in the history
fixes #1059
  • Loading branch information
Jake Champion committed Jul 18, 2023
1 parent 8f68d62 commit 20d634b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ function readBlobAsArrayBuffer(blob) {
function readBlobAsText(blob) {
var reader = new FileReader()
var promise = fileReaderReady(reader)
reader.readAsText(blob)
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type)
var encoding = match ? match[1] : 'utf-8'
reader.readAsText(blob, encoding)
return promise
}

Expand Down

0 comments on commit 20d634b

Please sign in to comment.