提交 b5c8bd0f 编写于 作者: T Tanguy Krotoff 提交者: Jake Champion

Fix statusText: undefined should give '' and null should give 'null'

上级 a8aa427d
......@@ -450,7 +450,7 @@ export function Response(bodyInit, options) {
this.type = 'default'
this.status = options.status === undefined ? 200 : options.status
this.ok = this.status >= 200 && this.status < 300
this.statusText = 'statusText' in options ? options.statusText : ''
this.statusText = options.statusText === undefined ? '' : '' + options.statusText
this.headers = new Headers(options.headers)
this.url = options.url || ''
this._initBody(bodyInit)
......
......@@ -694,6 +694,16 @@ exercise.forEach(function(exerciseMode) {
assert.equal(r.headers.get('content-type'), 'text/plain')
})
test('construct with undefined statusText', function() {
var r = new Response('', {statusText: undefined})
assert.equal(r.statusText, '')
})
test('construct with null statusText', function() {
var r = new Response('', {statusText: null})
assert.equal(r.statusText, 'null')
})
test('init object as first argument', function() {
var r = new Response({
status: 201,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册