Fix problem if content-type isn't provided by server
All checks were successful
CI / CI (push) Successful in 1m22s

This commit is contained in:
SileNce5k 2025-05-10 15:09:53 +02:00
parent 8570b2a204
commit 6a0350f13c
Signed by: SileNce
GPG key ID: B0A142BB4291B204

View file

@ -97,7 +97,8 @@ module.exports = {
return {value: 3, errorMessage: error.cause.message};
}
if(!res.ok) return {value: 1, errorMessage: res.status.toString()};
if(!res.headers.get('content-type').startsWith("image")) return {value: 2, errorMessage: ""};
const contentType = res.headers.get('content-type');
if(!contentType || !contentType.startsWith("image")) return {value: 2, errorMessage: contentType || "No content-type header"};
const stream = Readable.fromWeb(res.body)
await writeFile(path, stream);
return {value: 0, errorMessage: ""};