Skip to content

Conversation

@tkrotoff
Copy link
Contributor

@tkrotoff tkrotoff commented Jan 27, 2021

Inside Response constructor, this line:
this.statusText = 'statusText' in options ? options.statusText : '' is incorrect and should be:
this.statusText = options.statusText === undefined ? '' : '' + options.statusText

With Firefox 84, Chrome 88, WebKit 605.1.15 native Response gives:

  • new Response('').statusText ==> ""
  • new Response('', {statusText: undefined}).statusText ==> ""
  • new Response('', {statusText: null}).statusText ==> "null" (yes a string)
  • new Response('', {statusText: ''}).statusText ==> ""
  • new Response('', {statusText: 'hello'}).statusText ==> "hello"
  • new Response('', {statusText: 0}).statusText ==> '0'
  • new Response('', {statusText: 1}).statusText ==> '1'
Screenshots

chrome

firefox

webkit

With whatwg-fetch 3.0.5 you get:

  • new Response('').statusText ==> "" ==> OK
  • new Response('', {statusText: undefined}).statusText ==> undefined ==> KO (should be "")
  • new Response('', {statusText: null}).statusText ==> null ==> KO (should be a string)
  • new Response('', {statusText: ''}).statusText ==> "" ==> OK
  • new Response('', {statusText: 'hello'}).statusText ==> "hello" ==> OK
  • new Response('', {statusText: 0}).statusText ==> 0 ==> KO (should be a string)
  • new Response('', {statusText: 1}).statusText ==> 1 ==> KO (should be a string)
@tkrotoff tkrotoff changed the title Fix statusText Fix Response.statusText Jan 27, 2021
tkrotoff added a commit to tkrotoff/fetch that referenced this pull request Jan 27, 2021
@JakeChampion JakeChampion self-requested a review January 28, 2021 12:08
@JakeChampion JakeChampion merged commit b5c8bd0 into JakeChampion:master Jan 28, 2021
@tkrotoff tkrotoff deleted the fix-statusText branch January 28, 2021 12:23
@JakeChampion
Copy link
Owner

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants