fix: treat empty IMGW warning products as no warnings

This commit is contained in:
zv
2026-06-12 21:51:44 +02:00
parent 1ff76cf847
commit 3309e03acb
5 changed files with 31 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
export function isImgwNoProductsResponse(value: unknown) {
if (!value || typeof value !== "object") return false;
const response = value as { status?: unknown; message?: unknown };
return response.status === false
&& typeof response.message === "string"
&& response.message.toLocaleLowerCase("en-US").includes("no products were found");
}
export async function readImgwResponseBody(response: Response) {
const text = await response.text().catch(() => "");
if (!text) return { text, json: null as unknown };
try {
return { text, json: JSON.parse(text) as unknown };
} catch {
return { text, json: null as unknown };
}
}