Defensively guard against dangling ? from qualifiers

This commit is contained in:
Lane Seppala
2023-06-02 16:07:51 +00:00
parent 83edbc93dd
commit 5961fd4755
4 changed files with 22 additions and 4 deletions
+15 -1
View File
@@ -20,7 +20,7 @@ test("Parses CLI output", async () => {
});
describe("ComponentDetection.makePackageUrl", () => {
test("returns a valid package url", () => {
test("returns a valid package url from saturated object", () => {
const packageUrl = ComponentDetection.makePackageUrl({
Scheme: "pkg",
Type: "npm",
@@ -36,4 +36,18 @@ describe("ComponentDetection.makePackageUrl", () => {
"pkg:npm/github/[email protected]?arch=amd64&os=linux"
);
});
test("returns valid package url without dangling ? with empty qualifers", () => {
const packageUrl = ComponentDetection.makePackageUrl({
Scheme: "pkg",
Type: "npm",
Namespace: "github",
Name: "component-detection-action",
Version: "0.0.2",
Qualifiers: { },
});
expect(packageUrl).toBe(
"pkg:npm/github/[email protected]"
);
});
});