Skip to content

Commit f44cba8

Browse files
committed
Don't get ICC color space files if required API options are missing
This commit improves validation of the API options for the ICC color space logic. If `useWasm` is `true` but the corresponding `wasmUrl` or `iccUrl` API options are not provided we can avoid requesting files with `null` URLs which always results in a 404 response.
1 parent d86045e commit f44cba8

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/core/colorspace_utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class ColorSpaceUtils {
289289
}
290290

291291
static get cmyk() {
292-
if (IccColorSpace.isUsable) {
292+
if (CmykICCBasedCS.isUsable) {
293293
try {
294294
return shadow(this, "cmyk", new CmykICCBasedCS());
295295
} catch {

src/core/icc_colorspace.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@ class IccColorSpace extends ColorSpace {
130130
static get isUsable() {
131131
let isUsable = false;
132132
if (this.#useWasm) {
133-
try {
134-
this._module = QCMS._module = this.#load();
135-
isUsable = !!this._module;
136-
} catch (e) {
137-
warn(`ICCBased color space: "${e}".`);
133+
if (this.#wasmUrl) {
134+
try {
135+
this._module = QCMS._module = this.#load();
136+
isUsable = !!this._module;
137+
} catch (e) {
138+
warn(`ICCBased color space: "${e}".`);
139+
}
140+
} else {
141+
warn("No ICC color space support due to missing `wasmUrl` API option");
138142
}
139143
}
140144

@@ -169,6 +173,19 @@ class CmykICCBasedCS extends IccColorSpace {
169173
static setOptions({ iccUrl }) {
170174
this.#iccUrl = iccUrl;
171175
}
176+
177+
static get isUsable() {
178+
let isUsable = false;
179+
if (IccColorSpace.isUsable) {
180+
if (this.#iccUrl) {
181+
isUsable = true;
182+
} else {
183+
warn("No CMYK ICC profile support due to missing `iccUrl` API option");
184+
}
185+
}
186+
187+
return shadow(this, "isUsable", isUsable);
188+
}
172189
}
173190

174191
export { CmykICCBasedCS, IccColorSpace };

0 commit comments

Comments
 (0)