Skip to content

Commit

Permalink
Merge pull request #406 from cuixq:fix
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 718654190
  • Loading branch information
copybara-github committed Jan 23, 2025
2 parents 56d881c + cfdfd4b commit afdaa52
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


balanced-match:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ func TestExtractor_Extract_v1(t *testing.T) {
},
},
},
{
Name: "package with no version in header",
InputConfig: extracttest.ScanInputMockConfig{
Path: "testdata/no-version.v1.lock",
},
WantInventory: []*extractor.Inventory{
{
Name: "balanced-match",
Version: "1.0.2",
Locations: []string{"testdata/no-version.v1.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
},
},
},
{
Name: "two packages",
InputConfig: extracttest.ScanInputMockConfig{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func groupYarnPackageDescriptions(ctx context.Context, scanner *bufio.Scanner) (
func extractYarnPackageName(header string) string {
// Header format: @my-scope/my-first-package@my-scope/my-first-package#commit=hash
str := strings.TrimPrefix(header, "\"")
str = strings.TrimSuffix(str, ":")
str, _, _ = strings.Cut(str, ",")

isScoped := strings.HasPrefix(str, "@")
Expand Down

0 comments on commit afdaa52

Please sign in to comment.