Skip to content
Snippets Groups Projects
Commit 47bd56f1 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix(pypi): normalize name before compare

parent 6d82d7b4
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,10 @@ module.exports = { ...@@ -7,6 +7,10 @@ module.exports = {
getDependency, getDependency,
}; };
function normalizeName(input) {
return input.toLowerCase().replace('-', '_');
}
async function getDependency(purl, config = {}) { async function getDependency(purl, config = {}) {
const { fullname: depName } = purl; const { fullname: depName } = purl;
let hostUrl = 'https://pypi.org/pypi/'; let hostUrl = 'https://pypi.org/pypi/';
...@@ -24,9 +28,11 @@ async function getDependency(purl, config = {}) { ...@@ -24,9 +28,11 @@ async function getDependency(purl, config = {}) {
logger.debug({ depName }, 'pip package not found'); logger.debug({ depName }, 'pip package not found');
return null; return null;
} }
if (!(dep.info && dep.info.name.toLowerCase() === depName.toLowerCase())) { if (
!(dep.info && normalizeName(dep.info.name) === normalizeName(depName))
) {
logger.warn( logger.warn(
{ lookupName: depName, returnedName: dep.name }, { lookupName: depName, returnedName: dep.info.name },
'Returned name does not match with requested name' 'Returned name does not match with requested name'
); );
return null; return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment