Skip to content

Commit

Permalink
Improved fetching license information for npm packages
Browse files Browse the repository at this point in the history
Signed-off-by: Jacek Puchta <jacek.puchta@dotdata.com>
  • Loading branch information
puchta committed Oct 26, 2023
1 parent 325d61a commit 7718861
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,11 @@ export const getNpmMetadata = async function (pkgList) {
body = res.body;
metadata_cache[key] = body;
}
p.description = body.description;
p.license = body.license;
p.description = body.versions?.[p.version]?.description || body.description;
p.license =
body.versions?.[p.version]?.license ||
body.license ||
(await getRepoLicense(body.repository?.url, undefined);
if (body.repository && body.repository.url) {
p.repository = { url: body.repository.url };
}
Expand Down Expand Up @@ -3095,6 +3098,9 @@ export const getRepoLicense = async function (repoUrl, repoMetadata) {
if (!repoUrl) {
repoUrl = toGitHubUrl(repoMetadata);
}
if (repoUrl.startsWith("git://") && repoUrl.endsWith(".git")) {
repoUrl = repoUrl.replace("git://", "https://").slice(0, -4);
}
// Perform github lookups
if (repoUrl.indexOf("github.com") > -1) {
let apiUrl = repoUrl.replace(
Expand Down

0 comments on commit 7718861

Please sign in to comment.