Fix latestVersion returning a version string not in the given version list
Fixes badges/shields#337
This commit is contained in:
parent
458b788bcd
commit
f935a1ad03
|
@ -3272,7 +3272,7 @@ function latestVersion(versions) {
|
|||
versions = versions.filter(function(version) {
|
||||
return (/^v?[0-9]/).test(version);
|
||||
});
|
||||
versions = versions.map(function(version) {
|
||||
semver_versions = versions.map(function(version) {
|
||||
var matches = /^(v?[0-9]+)(\.[0-9]+)?(-.*)?$/.exec(version);
|
||||
if (matches) {
|
||||
version = matches[1] + (matches[2] ? matches[2] : '.0') + '.0' + (matches[3] ? matches[3] : '');
|
||||
|
@ -3280,7 +3280,8 @@ function latestVersion(versions) {
|
|||
return version;
|
||||
});
|
||||
try {
|
||||
version = semver.maxSatisfying(versions, '');
|
||||
version = semver.maxSatisfying(semver_versions, '');
|
||||
version = versions[semver_versions.indexOf(version)];
|
||||
} catch(e) {
|
||||
versions = versions.sort();
|
||||
version = versions[versions.length - 1];
|
||||
|
|
Loading…
Reference in New Issue
Block a user