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) {
|
if (!url) {
|
||||||
throw new Error("getDocument - no `url` parameter provided.");
|
throw new Error("getDocument - no `url` parameter provided.");
|
||||||
}
|
}
|
||||||
let NetworkStream;
|
// eslint-disable-next-line no-nested-ternary
|
||||||
|
const NetworkStream = isValidFetchUrl(url)
|
||||||
if (
|
? PDFFetchStream
|
||||||
typeof PDFJSDev !== "undefined" &&
|
: typeof PDFJSDev !== "undefined" &&
|
||||||
PDFJSDev.test("GENERIC") &&
|
PDFJSDev.test("GENERIC") &&
|
||||||
isNodeJS
|
isNodeJS
|
||||||
) {
|
? PDFNodeStream
|
||||||
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
|
|
||||||
: PDFNetworkStream;
|
: PDFNetworkStream;
|
||||||
}
|
|
||||||
|
|
||||||
networkStream = new NetworkStream({
|
networkStream = new NetworkStream({
|
||||||
url,
|
url,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user