mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-14 01:04:04 +02:00
Merge pull request #20931 from Snuffleupagus/rm-factory-name-validation
Remove explicit `name`/`filename` validation in the `BaseCMapReaderFactory`, `BaseStandardFontDataFactory`, and `BaseWasmFactory` classes
This commit is contained in:
commit
ab228da9ce
@ -34,17 +34,12 @@ class BaseCMapReaderFactory {
|
||||
"Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided."
|
||||
);
|
||||
}
|
||||
if (!name) {
|
||||
throw new Error("CMap name must be specified.");
|
||||
}
|
||||
const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
|
||||
|
||||
return this._fetch(url)
|
||||
.then(cMapData => ({ cMapData, isCompressed: this.isCompressed }))
|
||||
.catch(reason => {
|
||||
throw new Error(
|
||||
`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`
|
||||
);
|
||||
throw new Error(`Unable to load CMap data at: ${url}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +33,6 @@ class BaseStandardFontDataFactory {
|
||||
"Ensure that the `standardFontDataUrl` API parameter is provided."
|
||||
);
|
||||
}
|
||||
if (!filename) {
|
||||
throw new Error("Font filename must be specified.");
|
||||
}
|
||||
const url = `${this.baseUrl}${filename}`;
|
||||
|
||||
return this._fetch(url).catch(reason => {
|
||||
|
||||
@ -31,9 +31,6 @@ class BaseWasmFactory {
|
||||
if (!this.baseUrl) {
|
||||
throw new Error("Ensure that the `wasmUrl` API parameter is provided.");
|
||||
}
|
||||
if (!filename) {
|
||||
throw new Error("Wasm filename must be specified.");
|
||||
}
|
||||
const url = `${this.baseUrl}${filename}`;
|
||||
|
||||
return this._fetch(url).catch(reason => {
|
||||
|
||||
@ -247,7 +247,7 @@ describe("cmap", function () {
|
||||
} catch (reason) {
|
||||
expect(reason).toBeInstanceOf(Error);
|
||||
const message = reason.message;
|
||||
expect(message.startsWith("Unable to load CMap at: ")).toEqual(true);
|
||||
expect(message.startsWith("Unable to load CMap data at: ")).toEqual(true);
|
||||
expect(message.endsWith("/external/bcmaps/Adobe-Japan1-1")).toEqual(true);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user