This repository has been archived on 2025-12-24. You can view files and clone it, but cannot push or open issues or pull requests.
site-template/packages/imagetoolsOSR/api/utils/throwErrorIfUnsupported.js
2025-03-07 14:59:06 +01:00

15 lines
465 B
JavaScript

// @ts-check
import { supportedImageTypes } from "../../utils/runtimeChecks.js";
export default function throwErrorIfUnsupported(src, ext) {
if (!ext && typeof ext !== "string") {
throw new Error(`Failed to load ${src}; Invalid image format`);
}
if (ext && !supportedImageTypes.includes(ext.toLowerCase())) {
throw new Error(
`Failed to load ${src}; Invalid image format ${ext} or the format is not supported by astro-imagetools`
);
}
}