Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdaf44fb

Browse files
authored
improved checksum parsing (#280)
Signed-off-by: Brian DeHamer <bdehamer@github.com>
1 parenteda10f8 commitdaf44fb

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

‎__tests__/subject.test.ts‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,22 @@ badline
473473
'187dcd1506a170337415589ff00c8743f19d41cc31fca246c2739dfd450d0b9d'
474474
}
475475
})
476+
expect(subjects).toContainEqual({
477+
name:'demo_0.0.1_darwin_arm64',
478+
digest:{
479+
sha512:
480+
'5d8b4751ef31f9440d843fcfa4e53ca2e25b1cb1f13fd355fdc7c24b41fe645293291ea9297ba3989078abb77ebbaac66be073618a9e4974dbd0361881d4c718'
481+
}
482+
})
476483
})
477484
})
478485
})
479486

480487
describe('when specifying a subject checksums string',()=>{
481488
constchecksums=`
482489
f861e68a080799ca83104630b56abb90d8dbcc5f8b5a8639cb691e269838f29e demo_0.0.1_linux_386
483-
187dcd1506a170337415589ff00c8743f19d41cc31fca246c2739dfd450d0b9ddemo_0.0.1_linux_amd64
484-
9ecbf449e286a8a8748c161c52aa28b6b2fc64ab86f94161c5d1b3abc18156c5demo_0.0.1_linux_arm64`
490+
187dcd1506a170337415589ff00c8743f19d41cc31fca246c2739dfd450d0b9d*demo_0.0.1_linux_amd64
491+
9ecbf449e286a8a8748c161c52aa28b6b2fc64ab86f94161c5d1b3abc18156c5 demo_0.0.1_linux_arm64`
485492

486493
it('returns the multiple subjects',async()=>{
487494
constinputs:SubjectInputs={
@@ -500,6 +507,20 @@ f861e68a080799ca83104630b56abb90d8dbcc5f8b5a8639cb691e269838f29e demo_0.0.1_lin
500507
'f861e68a080799ca83104630b56abb90d8dbcc5f8b5a8639cb691e269838f29e'
501508
}
502509
})
510+
expect(subjects).toContainEqual({
511+
name:'demo_0.0.1_linux_amd64',
512+
digest:{
513+
sha256:
514+
'187dcd1506a170337415589ff00c8743f19d41cc31fca246c2739dfd450d0b9d'
515+
}
516+
})
517+
expect(subjects).toContainEqual({
518+
name:'demo_0.0.1_linux_arm64',
519+
digest:{
520+
sha256:
521+
'9ecbf449e286a8a8748c161c52aa28b6b2fc64ab86f94161c5d1b3abc18156c5'
522+
}
523+
})
503524
})
504525
})
505526

‎dist/index.js‎

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎src/subject.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,14 @@ const getSubjectFromChecksumsString = (checksums: string): Subject[] => {
181181
continue
182182
}
183183

184-
// Swallow the type identifier character at the beginning of the name
185-
constname=record.slice(delimIndex+2)
184+
// It's common for checksum records to have a leading flag character before
185+
// the artifact name. It will be either a '*' or a space.
186+
constflag_and_name=record.slice(delimIndex+1)
187+
constname=
188+
flag_and_name.startsWith('*')||flag_and_name.startsWith(' ')
189+
?flag_and_name.slice(1)
190+
:flag_and_name
191+
186192
constdigest=record.slice(0,delimIndex)
187193

188194
if(!HEX_STRING_RE.test(digest)){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp