From a973d4a4e58cadde8637fc40b320aec634188b9a Mon Sep 17 00:00:00 2001 From: Boni Garcia Date: Thu, 25 Jul 2024 16:54:37 +0200 Subject: [PATCH] Improve logic for latest driver version detection --- .../wdm/versions/VersionDetector.java | 17 ++++++++++------- .../wdm/test/edge/EdgeLatestVersionTest.java | 5 +++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/bonigarcia/wdm/versions/VersionDetector.java b/src/main/java/io/github/bonigarcia/wdm/versions/VersionDetector.java index 695578ac8..17ec1f477 100644 --- a/src/main/java/io/github/bonigarcia/wdm/versions/VersionDetector.java +++ b/src/main/java/io/github/bonigarcia/wdm/versions/VersionDetector.java @@ -141,14 +141,17 @@ public Optional getDriverVersionFromRepository( } Optional 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()) { diff --git a/src/test/java/io/github/bonigarcia/wdm/test/edge/EdgeLatestVersionTest.java b/src/test/java/io/github/bonigarcia/wdm/test/edge/EdgeLatestVersionTest.java index f2e6e2829..85f6d32a9 100644 --- a/src/test/java/io/github/bonigarcia/wdm/test/edge/EdgeLatestVersionTest.java +++ b/src/test/java/io/github/bonigarcia/wdm/test/edge/EdgeLatestVersionTest.java @@ -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 osLabel = Optional.empty(); Optional driverVersionFromRepository = versionDetector .getDriverVersionFromRepository(driverVersion, driverUrl, - versionCharset, driverName, versionLabel, versionLabel, + versionCharset, driverName, stableLabel, releaseLabel, osLabel); assertThat(driverVersionFromRepository).isPresent(); String edgeVersion = driverVersionFromRepository.get();