Skip to content

Commit

Permalink
fix: throw error if URL is provided but fetch is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoaxel committed Jan 27, 2024
1 parent 40f8edd commit 75505cc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions PDFMergerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ export default class PDFMergerBase {

// see https://developer.mozilla.org/en-US/docs/Web/API/URL
if (input instanceof URL) {
if (typeof fetch === 'undefined') {
throw new Error('fetch is not defined. You need to use a polyfill for this to work in Node.js.')
}
const res = await fetch(input)
const aBuffer = await res.arrayBuffer()
return new Uint8Array(aBuffer)
Expand Down

0 comments on commit 75505cc

Please sign in to comment.