Skip to content

Commit 7ec6fbc

Browse files
committed
fixup
1 parent 0db311b commit 7ec6fbc

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

lib/api/api-fetch/body.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const util = require('../../core/util')
44
const { finished } = require('stream')
55
const { ReadableStream, CountQueuingStrategy } = require('stream/web')
6-
const { AbortError, InvalidArgumentError } = require('../../core/errors')
6+
const { AbortError } = require('../../core/errors')
77

88
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
99
function extractBody (body) {
@@ -26,8 +26,13 @@ function extractBody (body) {
2626
} else if (
2727
body instanceof ArrayBuffer ||
2828
ArrayBuffer.isView(body) ||
29-
util.isBuffer(body)
29+
util.isBuffer(body) ||
30+
body instanceof DataView
3031
) {
32+
if (body instanceof DataView) {
33+
// TODO: Blob doesn't seem to work with DataView?
34+
body = body.buffer
35+
}
3136
return [{
3237
source: body
3338
}, null]

test/node-fetch/external-encoding.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// import chai from 'chai'
2-
// import { fetch } from '../../index.js'
1+
// const chai = require('chai')
2+
// const { fetch } = require('../../index.js')
33

44
// const { expect } = chai
55

test/node-fetch/response.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ describe('Response', () => {
187187
})
188188
})
189189

190-
// it('should support DataView as body', () => {
191-
// const encoder = new TextEncoder()
192-
// const res = new Response(new DataView(encoder.encode('a=1').buffer))
193-
// return res.text().then(result => {
194-
// expect(result).to.equal('a=1')
195-
// })
196-
// })
190+
it('should support DataView as body', () => {
191+
const encoder = new TextEncoder()
192+
const res = new Response(new DataView(encoder.encode('a=1').buffer))
193+
return res.text().then(result => {
194+
expect(result).to.equal('a=1')
195+
})
196+
})
197197

198198
it('should default to null as body', () => {
199199
const res = new Response()

0 commit comments

Comments
 (0)