Skip to content

Commit

Permalink
Improve logic for latest driver version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Jul 25, 2024
1 parent 19da22a commit a973d4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,17 @@ public Optional<String> getDriverVersionFromRepository(
}

Optional<String> result = Optional.empty();
String url = driverUrl + versionLabel;
if (!driverVersion.isPresent()) {
String osLabel = optOsLabel.isPresent() ? optOsLabel.get() : "";
String url = driverVersion.isPresent()
? driverUrl + latestLabel + "_" + driverVersion.get() + osLabel
: driverUrl + versionLabel;
if (!driverVersion.isPresent()
&& driverName.equalsIgnoreCase("msedgedriver")) {
result = readUrlContent(url, driverName, versionCharset);
}
if (result.isPresent()) {
String osLabel = optOsLabel.isPresent() ? optOsLabel.get() : "";
url = driverUrl + latestLabel + "_" + getMajorVersion(result.get())
+ osLabel;
if (result.isPresent()) {
url = driverUrl + latestLabel + "_"
+ getMajorVersion(result.get()) + osLabel;
}
}
result = readUrlContent(url, driverName, versionCharset);
if (result.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ void edgeVersionTest() throws Exception {
URL driverUrl = new URL("https://msedgedriver.azureedge.net/");
Charset versionCharset = UTF_16;
String driverName = "msedgedriver";
String versionLabel = "LATEST_STABLE";
String stableLabel = "LATEST_STABLE";
String releaseLabel = "LATEST_RELEASE";
Optional<String> osLabel = Optional.empty();

Optional<String> driverVersionFromRepository = versionDetector
.getDriverVersionFromRepository(driverVersion, driverUrl,
versionCharset, driverName, versionLabel, versionLabel,
versionCharset, driverName, stableLabel, releaseLabel,
osLabel);
assertThat(driverVersionFromRepository).isPresent();
String edgeVersion = driverVersionFromRepository.get();
Expand Down

0 comments on commit a973d4a

Please sign in to comment.