Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Response.statusText #897

Merged
merged 1 commit into from Jan 28, 2021
Merged

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

This is released in v3.6.0 -- https://github.com/github/fetch/releases/tag/v3.6.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants