download: Get latest build from last match instead of sorting

This fails for 12L: SP2A.220305.013.A3 < SQ1D.220205.004. Google always
adds builds to the bottom anyway, so just pick the last matched URL.
This commit is contained in:
Danny Lin 2022-03-22 19:14:00 -07:00 committed by Daniel Micay
parent 4e0a7e1af2
commit 95f25fde97

View file

@ -64,7 +64,7 @@ async function getUrl(type: ImageType, buildId: string, device: string, cache: I
}
if (buildId == 'latest') {
return matches.map(m => m[1]).sort((a, b) => b.localeCompare(a))[0]
return matches[matches.length - 1][1]
}
return matches[0][1]
}