Skip to content

Commit f42bb13

Browse files
olaalsmarianards
andcommitted
Update frontend/src/api/client.ts
Co-authored-by: Mariana Ricardo Santos <108514046+marianards@users.noreply.github.com>
1 parent de92412 commit f42bb13

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

frontend/src/api/client.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -502,16 +502,25 @@ export async function getInspectionRecordThermalImage(
502502
throw new Error(`${response.status}: ${text}`);
503503
}
504504
const buffer = await response.arrayBuffer();
505+
const width = parseInt(response.headers.get("X-Image-Width") ?? "", 10);
506+
const height = parseInt(response.headers.get("X-Image-Height") ?? "", 10);
507+
if (
508+
!Number.isFinite(width) ||
509+
width <= 0 ||
510+
!Number.isFinite(height) ||
511+
height <= 0
512+
) {
513+
throw new Error(
514+
"Thermal image response is missing valid dimension headers"
515+
);
516+
}
517+
505518
return {
506519
temperatures: new Float32Array(buffer),
507-
width: parseInt(response.headers.get("X-Image-Width") ?? "0", 10),
508-
height: parseInt(response.headers.get("X-Image-Height") ?? "0", 10),
509-
minTemperature: parseFloat(
510-
response.headers.get("X-Temperature-Min") ?? "0"
511-
),
512-
maxTemperature: parseFloat(
513-
response.headers.get("X-Temperature-Max") ?? "0"
514-
),
520+
width,
521+
height,
522+
minTemperature: parseFloat(response.headers.get("X-Temperature-Min") ?? "0"),
523+
maxTemperature: parseFloat(response.headers.get("X-Temperature-Max") ?? "0"),
515524
};
516525
}
517526

0 commit comments

Comments
 (0)