From 57d37508058fb89a2b9b1d5995fffbbabfd9e975 Mon Sep 17 00:00:00 2001 From: Jacek Puchta Date: Thu, 26 Oct 2023 12:18:30 +0200 Subject: [PATCH] fetching license info from github repo - if none in npm metadata Signed-off-by: Jacek Puchta --- utils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils.js b/utils.js index 15ec0c32b..0b44729f9 100644 --- a/utils.js +++ b/utils.js @@ -332,10 +332,11 @@ export const getNpmMetadata = async function (pkgList) { } p.description = body.versions?.[p.version]?.description || - body.description + body.description; p.license = body.versions?.[p.version]?.license || - body.license + body.license || + await getRepoLicense(body.repository?.url, undefined); if (body.repository && body.repository.url) { p.repository = { url: body.repository.url }; } @@ -3099,6 +3100,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(