Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public CargoComponent(string name, string version, string author = null, string

public override ComponentType Type => ComponentType.Cargo;

public override PackageURL PackageUrl => new PackageURL("cargo", string.Empty, this.Name, this.Version, null, string.Empty);
public override PackageURL PackageUrl => new PackageURL("cargo", null, this.Name, this.Version, null, null);

protected override string ComputeId() => $"{this.Name} {this.Version} - {this.Type}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,16 @@ public void CocoaPodNameShouldPurlWithCustomQualifier()

packageOne.PackageUrl.ToString().Should().Be("pkg:cocoapods/[email protected]?repository_url=https://custom_repo.example.com/path/to/repo/specs.git");
}

[TestMethod]
public void CargoShouldSupportPurl()
{
// https://github.com/package-url/purl-spec/blob/main/PURL-TYPES.rst#cargo
var packageOne = new CargoComponent("rand", "0.7.2");
var packageTwo = new CargoComponent("rand", "0.7.3", "RodneyRichardson", "MIT", "https://custom_repo.example.com/path/to/repo/specs.git");

packageOne.PackageUrl.Type.Should().Be("cargo");
packageOne.PackageUrl.ToString().Should().Be("pkg:cargo/[email protected]");
packageTwo.PackageUrl.ToString().Should().Be("pkg:cargo/[email protected]");
}
}