Skip to content

Commit d7eb313

Browse files
committed
getDownloadSize: defer to parseInt for detecting hex
1 parent 3f174e4 commit d7eb313

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/fastboot.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,9 @@ export class FastbootDevice {
384384
"max-download-size"
385385
))!.toLowerCase();
386386
if (resp) {
387-
let size
388-
try {
389-
// Some bootloaders return decimal
390-
size = parseInt(resp, 10)
391-
} catch (e) {
392-
// Some bootloaders return hex
393-
size = parseInt(resp, 16)
394-
}
395-
return Math.min(size, MAX_DOWNLOAD_SIZE);
387+
// Some bootloaders return hex, some return decimal
388+
// parseInt handles both by detecting the "0x" prefix
389+
return Math.min(parseInt(resp), MAX_DOWNLOAD_SIZE);
396390
}
397391
} catch (error) {
398392
/* Failed = no value, fallthrough */

0 commit comments

Comments
 (0)