Skip to content

Commit

Permalink
Fix being unable to properly update when a driver version ends with a…
Browse files Browse the repository at this point in the history
… 3 digit number. For example, chromedriver 98.0.4758.102 was being read as a lower version than 98.0.4758.80 due to alphanumeric sorting and .80 coming before .102.
  • Loading branch information
awbuboltz committed Feb 17, 2022
1 parent 9fd6294 commit 4870239
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/binaries/chrome_xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,25 @@ export class ChromeXml extends XmlConfigSource {
this.getOsTypeName() + (this.getOsTypeName() === 'win' ? '32' : '64');

if (item.includes(osTypeNameAndArch)) {
itemFound = item;
// We've already found a match previously, get the patch version from it
let previousItemVersionParts = itemFound.split('/')[0].split('.');

// This is the item that has just been found on this pass check the patch version
let possibleItemVersionParts = item.split('/')[0].split('.');

// Make sure both semvers have the same number of decimals so we can compare
if (previousItemVersionParts.length === possibleItemVersionParts.length) {
let previousItemVersion =
+previousItemVersionParts[previousItemVersionParts.length - 1];
let possibleItemVersion =
+possibleItemVersionParts[possibleItemVersionParts.length - 1];
// Compare the current item to the one that was found last time, it is possible
// that the previous item is version 50.10.100 and the new item is 50.10.20
// which is not actually higher (100 > 20)
itemFound = possibleItemVersion > previousItemVersion ? item : itemFound;
} else {
itemFound = item;
}
}
}
}
Expand Down

0 comments on commit 4870239

Please sign in to comment.