Skip to content

Commit a98a2bd

Browse files
committed
fix: reworked the two todos
1 parent 406e36f commit a98a2bd

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/components/Quickfix.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ export const DiffHighlighter: FunctionComponent<DiffHighlighterProps> = ({
2424
return <span className="font-mono text-xs">{oldVersionPurl}</span>;
2525
}
2626

27-
const { name, version } = PackageURL.fromString(oldVersionPurl);
27+
const { namespace, name, version } = PackageURL.fromString(oldVersionPurl);
28+
const fullName = namespace ? `${namespace}/${name}` : name;
2829

2930
if (newVersionPurl && isValidPackagePurl(newVersionPurl)) {
3031
const { version: newVer } = PackageURL.fromString(newVersionPurl);
31-
const differences = diffChars(name + "@" + version, name + "@" + newVer);
32+
const differences = diffChars(
33+
fullName + "@" + version,
34+
fullName + "@" + newVer,
35+
);
3236

3337
return (
3438
<div className="font-mono text-xs">
@@ -64,8 +68,10 @@ function renderQuickFixText(
6468
switch (type) {
6569
case "npm":
6670
return `npm install ${fullName}@${version}`;
67-
case "golang":
68-
return `go get ${fullName}@v${version}`;
71+
case "golang": {
72+
const goVersion = version?.startsWith("v") ? version : `v${version}`;
73+
return `go get ${fullName}@${goVersion}`;
74+
}
6975
case "pypi":
7076
return `pip install ${fullName}==${version}`;
7177
case "cargo":
@@ -97,7 +103,6 @@ const Quickfix: FunctionComponent<{ vuln: DetailedDependencyVulnDTO }> = ({
97103
vuln,
98104
}) => {
99105
const fixedVersionPurl = getFixedVersionPurl(vuln);
100-
console.log(vuln);
101106
const ecosystemUpdate = renderQuickFixText(fixedVersionPurl);
102107

103108
if (!vuln.vulnerabilityPath || vuln.vulnerabilityPath.length === 0) {

0 commit comments

Comments
 (0)