Remove explicit name/filename validation in the BaseCMapReaderFactory, BaseStandardFontDataFactory, and BaseWasmFactory classes

Given that these classes are only used from the "FetchBinaryData" message handler, the `name`/`filename` parameters should never actually be missing and if they are that's a bug elsewhere in the code-base.
Furthermore a missing `name`/`filename` parameter would result in a "nonsense" URL and the actual data fetching would then fail instead, hence keeping this old validation code just doesn't seem necessary.
This commit is contained in:
Jonas Jenwald 2026-03-20 15:50:26 +01:00
parent ff1af5a058
commit 5299eb2b83
4 changed files with 2 additions and 13 deletions

View File

@ -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}`);
});
}

View File

@ -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 => {

View File

@ -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 => {

View File

@ -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);
}
});