Skip to content

Commit b5c8bd0

Browse files
tkrotoffJakeChampion
authored andcommitted
Fix statusText: undefined should give '' and null should give 'null'
1 parent a8aa427 commit b5c8bd0

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export function Response(bodyInit, options) {
450450
this.type = 'default'
451451
this.status = options.status === undefined ? 200 : options.status
452452
this.ok = this.status >= 200 && this.status < 300
453-
this.statusText = 'statusText' in options ? options.statusText : ''
453+
this.statusText = options.statusText === undefined ? '' : '' + options.statusText
454454
this.headers = new Headers(options.headers)
455455
this.url = options.url || ''
456456
this._initBody(bodyInit)

test/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,16 @@ exercise.forEach(function(exerciseMode) {
694694
assert.equal(r.headers.get('content-type'), 'text/plain')
695695
})
696696

697+
test('construct with undefined statusText', function() {
698+
var r = new Response('', {statusText: undefined})
699+
assert.equal(r.statusText, '')
700+
})
701+
702+
test('construct with null statusText', function() {
703+
var r = new Response('', {statusText: null})
704+
assert.equal(r.statusText, 'null')
705+
})
706+
697707
test('init object as first argument', function() {
698708
var r = new Response({
699709
status: 201,

0 commit comments

Comments
 (0)