Skip to content

Commit

Permalink
fix: remove unnecessary check for response.buffer
Browse files Browse the repository at this point in the history
If TypeScript is to be believed, cross-fetch's Response never returns buffer, so this check is unnecessary.
  • Loading branch information
wojtekmaj committed Jan 19, 2024
1 parent 64f7bba commit 660265a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-suns-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@react-pdf/image': patch
---

Remove unnecessary check for response.buffer
4 changes: 1 addition & 3 deletions packages/image/src/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ const fetchLocalFile = src =>
const fetchRemoteFile = async (uri, options) => {
const response = await fetch(uri, options);

const buffer = await (response.buffer
? response.buffer()
: response.arrayBuffer());
const buffer = await response.arrayBuffer();

return buffer.constructor.name === 'Buffer' ? buffer : Buffer.from(buffer);
};
Expand Down

0 comments on commit 660265a

Please sign in to comment.