Skip to content

Commit c63c8a1

Browse files
committed
fix: tolerate null bugs URLs
Currently, if the bugs URL returned from `package.json`, which is processed through [hosted-git-info](https://github.com/npm/hosted-git-info), is falsy, an error is thrown. However, hosted-git-info may well return a falsy bugs URL. This can happen when there is no bugs URL in the repo, but hosted-git-info tries to infer one, but one cannot be inferred, for example if the repository URL is a SourceHut URL. This is described here: npm/hosted-git-info#213 For this reason, we should tolerate falsy URLs and fall back to whatever is defined in `bugs.js`, in this case being sent to https://www.npmjs.com/package/<packageName>.
1 parent 6ec6ff0 commit c63c8a1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/commands/bugs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class Bugs extends PackageUrlCmd {
2222
// try to get it from the repo, if possible
2323
const info = this.hostedFromMani(mani)
2424
if (info) {
25-
return info.bugs()
25+
const infoUrl = info.bugs();
26+
if (infoUrl) {
27+
return infoUrl;
28+
}
2629
}
2730

2831
// just send them to the website, hopefully that has some info!

0 commit comments

Comments
 (0)