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

fix(pypi): use better version detection

Closes #4047
parent e374f2c2
No related branches found
No related tags found
No related merge requests found
......@@ -116,7 +116,7 @@ async function getSimpleDependency(depName, hostUrl) {
const links = root.querySelectorAll('a');
const versions = new Set();
for (const link of links) {
const result = extractVersionFromLinkText(link.text);
const result = extractVersionFromLinkText(link.text, depName);
if (result) {
versions.add(result);
}
......@@ -136,11 +136,11 @@ async function getSimpleDependency(depName, hostUrl) {
}
}
function extractVersionFromLinkText(text) {
const versionRegexp = /\d+(\.\d+)+/;
const result = text.match(versionRegexp);
if (result && result.length > 0) {
return result[0];
function extractVersionFromLinkText(text, depName) {
const prefix = `${depName}-`;
const suffix = '.tar.gz';
if (!(text.startsWith(prefix) && text.endsWith(suffix))) {
return null;
}
return null;
return text.replace(prefix, '').replace(/\.tar\.gz$/, '');
}
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