File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments