Skip to content

Commit abcd9c8

Browse files
authored
fix: minors bugs in the package pannel (#256)
* fix: minors bugs in the package pannel * fix(author): return Unknown if object is empty
1 parent ceded82 commit abcd9c8

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

bin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ defaultScannerCommand("from <package>")
5555
await commands.scanner.from(...options);
5656
});
5757

58-
defaultScannerCommand("auto [package]", { includeOutput: false, strategy: vuln.strategies.SECURITY_WG })
58+
defaultScannerCommand("auto [package]", { includeOutput: false, strategy: vuln.strategies.NPM_AUDIT })
5959
.describe(i18n.getTokenSync("cli.commands.auto.desc"))
6060
.option("-k, --keep", i18n.getTokenSync("cli.commands.auto.option_keep"), false)
6161
.action(commands.scanner.auto);

esbuild.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ await Promise.all([
4141
"github-mark.png",
4242
"github-black.png",
4343
"npm-icon.svg",
44-
"nodejs.png",
44+
"node.png",
4545
"snyk.png",
4646
"sonatype.png",
4747
"avatar-default.png",

public/js/components/package/pannels/overview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class Overview {
1616

1717
get author() {
1818
const author = this.package.dependencyVersion.author;
19-
if (author === null) {
19+
if (author === null || !("name" in author)) {
2020
return "Unknown";
2121
}
2222

public/js/utils.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,21 @@ export function parseRepositoryUrl(repository = {}, defaultValue = null) {
6161
if (repository.url.startsWith("git://")) {
6262
return `https${repository.url.slice(3)}`;
6363
}
64-
return repository.url;
64+
if (repository.url.startsWith("git@")) {
65+
const execResult = /git@(?<platform>[a-zA-Z.]+):(?<repo>.+)\.git/gm.exec(repository.url);
66+
if (execResult === null) {
67+
return defaultValue;
68+
}
69+
70+
return `https://${execResult.groups.platform}/${execResult.groups.repo}`;
71+
}
72+
73+
try {
74+
return new URL(repository.url).href;
75+
}
76+
catch {
77+
return defaultValue;
78+
}
6579
}
6680

6781
export function createAvatarImageElement(email = null) {

0 commit comments

Comments
 (0)