improved checksum parsing (#280)

Signed-off-by: Brian DeHamer <bdehamer@github.com>
This commit is contained in:
Brian DeHamer
2025-08-26 16:07:15 -07:00
committed by GitHub
parent eda10f897a
commit daf44fb950
3 changed files with 37 additions and 6 deletions
Generated Vendored
+6 -2
View File
@@ -74225,8 +74225,12 @@ const getSubjectFromChecksumsString = (checksums) => {
if (delimIndex === -1) {
continue;
}
// Swallow the type identifier character at the beginning of the name
const name = record.slice(delimIndex + 2);
// It's common for checksum records to have a leading flag character before
// the artifact name. It will be either a '*' or a space.
const flag_and_name = record.slice(delimIndex + 1);
const name = flag_and_name.startsWith('*') || flag_and_name.startsWith(' ')
? flag_and_name.slice(1)
: flag_and_name;
const digest = record.slice(0, delimIndex);
if (!HEX_STRING_RE.test(digest)) {
throw new Error(`Invalid digest: ${digest}`);