diff --git a/rust/src/firefox.rs b/rust/src/firefox.rs index dac2da885a00e..c0ee53fc4ddc8 100644 --- a/rust/src/firefox.rs +++ b/rust/src/firefox.rs @@ -223,9 +223,11 @@ impl SeleniumManager for FirefoxManager { _ => { self.assert_online_or_err(OFFLINE_REQUEST_ERR_MSG)?; + let driver_version_url = + self.get_driver_mirror_versions_url_or_default(DRIVER_VERSIONS_URL); let driver_version = match parse_json_from_url::( self.get_http_client(), - DRIVER_VERSIONS_URL, + &driver_version_url, ) { Ok(driver_releases) => { let major_browser_version_int = diff --git a/rust/src/lib.rs b/rust/src/lib.rs index ab5c01b10a21e..756de692c6c19 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1288,6 +1288,26 @@ pub trait SeleniumManager { } } + fn get_driver_mirror_versions_url_or_default<'a>(&'a self, default_url: &'a str) -> String { + let driver_mirror_url = self.get_driver_mirror_url(); + if !driver_mirror_url.is_empty() { + let driver_versions_path = default_url.rfind('/').map(|i| &default_url[i + 1..]); + if let Some(path) = driver_versions_path { + let driver_mirror_versions_url = if driver_mirror_url.ends_with('/') { + format!("{}{}", driver_mirror_url, path) + } else { + format!("{}/{}", driver_mirror_url, path) + }; + self.get_logger().debug(format!( + "Using mirror URL to discover driver versions: {}", + driver_mirror_versions_url + )); + return driver_mirror_versions_url; + } + } + default_url.to_string() + } + fn get_driver_mirror_url_or_default<'a>(&'a self, default_url: &'a str) -> String { self.get_url_or_default(self.get_driver_mirror_url(), default_url) }