Merge pull request #19945 from Snuffleupagus/NetworkStream-rm-Node-Error
Remove Node.js-specific checks when using the Fetch API
This commit is contained in:
commit
f6e4b1cf4a
@ -462,32 +462,14 @@ function getDocument(src = {}) {
|
||||
if (!url) {
|
||||
throw new Error("getDocument - no `url` parameter provided.");
|
||||
}
|
||||
let NetworkStream;
|
||||
|
||||
if (
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("GENERIC") &&
|
||||
isNodeJS
|
||||
) {
|
||||
if (isValidFetchUrl(url)) {
|
||||
if (
|
||||
typeof fetch === "undefined" ||
|
||||
typeof Response === "undefined" ||
|
||||
!("body" in Response.prototype)
|
||||
) {
|
||||
throw new Error(
|
||||
"getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`."
|
||||
);
|
||||
}
|
||||
NetworkStream = PDFFetchStream;
|
||||
} else {
|
||||
NetworkStream = PDFNodeStream;
|
||||
}
|
||||
} else {
|
||||
NetworkStream = isValidFetchUrl(url)
|
||||
? PDFFetchStream
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
const NetworkStream = isValidFetchUrl(url)
|
||||
? PDFFetchStream
|
||||
: typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("GENERIC") &&
|
||||
isNodeJS
|
||||
? PDFNodeStream
|
||||
: PDFNetworkStream;
|
||||
}
|
||||
|
||||
networkStream = new NetworkStream({
|
||||
url,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user