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) { ...@@ -116,7 +116,7 @@ async function getSimpleDependency(depName, hostUrl) {
const links = root.querySelectorAll('a'); const links = root.querySelectorAll('a');
const versions = new Set(); const versions = new Set();
for (const link of links) { for (const link of links) {
const result = extractVersionFromLinkText(link.text); const result = extractVersionFromLinkText(link.text, depName);
if (result) { if (result) {
versions.add(result); versions.add(result);
} }
...@@ -136,11 +136,11 @@ async function getSimpleDependency(depName, hostUrl) { ...@@ -136,11 +136,11 @@ async function getSimpleDependency(depName, hostUrl) {
} }
} }
function extractVersionFromLinkText(text) { function extractVersionFromLinkText(text, depName) {
const versionRegexp = /\d+(\.\d+)+/; const prefix = `${depName}-`;
const result = text.match(versionRegexp); const suffix = '.tar.gz';
if (result && result.length > 0) { if (!(text.startsWith(prefix) && text.endsWith(suffix))) {
return result[0];
}
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.
Please register or to comment