Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tolerate null bugs URLs
Browse files Browse the repository at this point in the history
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>.
vladh committed Sep 12, 2023
1 parent 6ec6ff0 commit 05e4cd2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/commands/bugs.js
Original file line number Diff line number Diff line change
@@ -22,7 +22,10 @@ class Bugs extends PackageUrlCmd {
// try to get it from the repo, if possible
const info = this.hostedFromMani(mani)
if (info) {
return info.bugs()
const infoUrl = info.bugs();
if (infoUrl) {
return infoUrl;
}
}

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

0 comments on commit 05e4cd2

Please sign in to comment.