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: pass empty object to headers initializer to prevent crash on chrome 49 #235

Merged
merged 1 commit into from
Jun 6, 2023

Conversation

IlyaSemenov
Copy link
Contributor

ofetch crashes in Chrome 49 (which is the latest available Chrome on Windows XP which is still relevant in certain GovTech) with this message:

Failed to construct 'Headers': No matching constructor signature.

This is because older Chrome didn't treat new Headers(undefined) as new Headers().

This PR fixes this inconvenience with no noticeable burden for modern browsers (or code base readability).

Related: whatwg/fetch#185

@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #235 (26a3eda) into main (e27b50d) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #235      +/-   ##
==========================================
+ Coverage   86.26%   86.29%   +0.03%     
==========================================
  Files           5        5              
  Lines         415      416       +1     
  Branches       68       69       +1     
==========================================
+ Hits          358      359       +1     
  Misses         57       57              
Impacted Files Coverage Δ
src/fetch.ts 89.27% <100.00%> (+0.04%) ⬆️

@pi0 pi0 changed the title fix: prevent crash on Chrome 49 fix: pass empty object to headers initializer to prevent crash on chrome 49 Jun 6, 2023
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pi0 pi0 merged commit 5c24342 into unjs:main Jun 6, 2023
pi0 added a commit to DennisBetawerk/ofetch that referenced this pull request Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants