Remove some now redundant validation in getDocument
Given that we now check/validate all options properly this old code can be simplified.
This commit is contained in:
parent
831a526c10
commit
d6612b3427
@ -229,7 +229,7 @@ const DefaultStandardFontDataFactory =
|
|||||||
* already populated with data, or a parameter object.
|
* already populated with data, or a parameter object.
|
||||||
* @returns {PDFDocumentLoadingTask}
|
* @returns {PDFDocumentLoadingTask}
|
||||||
*/
|
*/
|
||||||
function getDocument(src) {
|
function getDocument(src = {}) {
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
if (typeof src === "string" || src instanceof URL) {
|
if (typeof src === "string" || src instanceof URL) {
|
||||||
src = { url: src };
|
src = { url: src };
|
||||||
@ -237,14 +237,6 @@ function getDocument(src) {
|
|||||||
src = { data: src };
|
src = { data: src };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof src !== "object") {
|
|
||||||
throw new Error("Invalid parameter in getDocument, need parameter object.");
|
|
||||||
}
|
|
||||||
if (!src.url && !src.data && !src.range) {
|
|
||||||
throw new Error(
|
|
||||||
"Invalid parameter object: need either .data, .range or .url"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const task = new PDFDocumentLoadingTask();
|
const task = new PDFDocumentLoadingTask();
|
||||||
const { docId } = task;
|
const { docId } = task;
|
||||||
|
|
||||||
@ -423,6 +415,9 @@ function getDocument(src) {
|
|||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||||
throw new Error("Not implemented: createPDFNetworkStream");
|
throw new Error("Not implemented: createPDFNetworkStream");
|
||||||
}
|
}
|
||||||
|
if (!url) {
|
||||||
|
throw new Error("getDocument - no `url` parameter provided.");
|
||||||
|
}
|
||||||
const createPDFNetworkStream = params => {
|
const createPDFNetworkStream = params => {
|
||||||
if (
|
if (
|
||||||
typeof PDFJSDev !== "undefined" &&
|
typeof PDFJSDev !== "undefined" &&
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user