Skip to content

Commit

Permalink
fix: minors bugs in the package pannel (#256)
Browse files Browse the repository at this point in the history
* fix: minors bugs in the package pannel

* fix(author): return Unknown if object is empty
  • Loading branch information
fraxken authored Nov 26, 2023
1 parent ceded82 commit abcd9c8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defaultScannerCommand("from <package>")
await commands.scanner.from(...options);
});

defaultScannerCommand("auto [package]", { includeOutput: false, strategy: vuln.strategies.SECURITY_WG })
defaultScannerCommand("auto [package]", { includeOutput: false, strategy: vuln.strategies.NPM_AUDIT })
.describe(i18n.getTokenSync("cli.commands.auto.desc"))
.option("-k, --keep", i18n.getTokenSync("cli.commands.auto.option_keep"), false)
.action(commands.scanner.auto);
Expand Down
2 changes: 1 addition & 1 deletion esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ await Promise.all([
"github-mark.png",
"github-black.png",
"npm-icon.svg",
"nodejs.png",
"node.png",
"snyk.png",
"sonatype.png",
"avatar-default.png",
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion public/js/components/package/pannels/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Overview {

get author() {
const author = this.package.dependencyVersion.author;
if (author === null) {
if (author === null || !("name" in author)) {
return "Unknown";
}

Expand Down
16 changes: 15 additions & 1 deletion public/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,21 @@ export function parseRepositoryUrl(repository = {}, defaultValue = null) {
if (repository.url.startsWith("git://")) {
return `https${repository.url.slice(3)}`;
}
return repository.url;
if (repository.url.startsWith("git@")) {
const execResult = /git@(?<platform>[a-zA-Z.]+):(?<repo>.+)\.git/gm.exec(repository.url);
if (execResult === null) {
return defaultValue;
}

return `https://${execResult.groups.platform}/${execResult.groups.repo}`;
}

try {
return new URL(repository.url).href;
}
catch {
return defaultValue;
}
}

export function createAvatarImageElement(email = null) {
Expand Down

0 comments on commit abcd9c8

Please sign in to comment.