Try to fix invalid versions.

This commit is contained in:
Tristan Lins 2014-09-07 04:18:15 +02:00
parent 6b4a1b80be
commit 1afa0ef9f7

View File

@ -1928,6 +1928,13 @@ function latestVersion(versions) {
versions = versions.filter(function(version) {
return (/^v?[0-9]/).test(version);
});
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] : '');
}
return version;
});
try {
version = semver.maxSatisfying(versions, '');
} catch(e) {