Skip to content

Commit f6e4b1c

Browse files
Merge pull request #19945 from Snuffleupagus/NetworkStream-rm-Node-Error
Remove Node.js-specific checks when using the Fetch API
2 parents 30bba5f + a882195 commit f6e4b1c

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

src/display/api.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -462,32 +462,14 @@ function getDocument(src = {}) {
462462
if (!url) {
463463
throw new Error("getDocument - no `url` parameter provided.");
464464
}
465-
let NetworkStream;
466-
467-
if (
468-
typeof PDFJSDev !== "undefined" &&
469-
PDFJSDev.test("GENERIC") &&
470-
isNodeJS
471-
) {
472-
if (isValidFetchUrl(url)) {
473-
if (
474-
typeof fetch === "undefined" ||
475-
typeof Response === "undefined" ||
476-
!("body" in Response.prototype)
477-
) {
478-
throw new Error(
479-
"getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`."
480-
);
481-
}
482-
NetworkStream = PDFFetchStream;
483-
} else {
484-
NetworkStream = PDFNodeStream;
485-
}
486-
} else {
487-
NetworkStream = isValidFetchUrl(url)
488-
? PDFFetchStream
465+
// eslint-disable-next-line no-nested-ternary
466+
const NetworkStream = isValidFetchUrl(url)
467+
? PDFFetchStream
468+
: typeof PDFJSDev !== "undefined" &&
469+
PDFJSDev.test("GENERIC") &&
470+
isNodeJS
471+
? PDFNodeStream
489472
: PDFNetworkStream;
490-
}
491473

492474
networkStream = new NetworkStream({
493475
url,

0 commit comments

Comments
 (0)