Skip to content

Commit 5f5a6f7

Browse files
committed
v0.33.1, fix #6
Signed-off-by: Vrtgs <mirza123.the.best@gmail.com>
1 parent 3da519d commit 5f5a6f7

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

thirtyfour/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "thirtyfour"
3-
version = "0.33.0"
3+
version = "0.33.1"
44
authors = ["Steve Pryde <steve@stevepryde.com>", "Vrtgs"]
55
edition = "2021"
66
license = "MIT OR Apache-2.0"

thirtyfour/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ pub enum WebDriverError {
143143
InsecureCertificate(WebDriverErrorInfo),
144144
#[error("An argument passed to the WebDriver server was invalid: {0}")]
145145
InvalidArgument(WebDriverErrorInfo),
146+
#[error("An argument passed to the WebDriver server was invalid: {0}")]
147+
InvalidUrl(url::ParseError),
146148
#[error("Invalid cookie domain: {0}")]
147149
InvalidCookieDomain(WebDriverErrorInfo),
148150
#[error("The element is in an invalid state: {0}")]

thirtyfour/src/session/handle.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use tokio::fs::File;
1010
use tokio::io::AsyncWriteExt;
1111
use tokio::runtime::RuntimeFlavor;
1212
use tokio::sync::OnceCell;
13-
use url::Url;
13+
use url::{ParseError, Url};
1414

1515
use crate::action_chain::ActionChain;
1616
use crate::common::command::{Command, FormatRequestData};
@@ -190,10 +190,17 @@ impl SessionHandle {
190190
/// # }
191191
/// ```
192192
pub async fn goto(&self, url: impl IntoArcStr) -> WebDriverResult<()> {
193-
let mut url = url.into();
194-
if !url.starts_with("http") {
195-
url = format!("https://{url}").into();
196-
}
193+
let url = url.into();
194+
195+
let parse_url = |url: Arc<str>| Url::parse(&url).map(|_| url);
196+
let url = parse_url(url.clone())
197+
.or_else(|e| match e {
198+
ParseError::RelativeUrlWithoutBase => {
199+
parse_url(("https://".to_string() + &*url).into())
200+
}
201+
e => Err(e),
202+
})
203+
.map_err(WebDriverError::InvalidUrl)?;
197204
self.cmd(Command::NavigateTo(url)).await?;
198205
Ok(())
199206
}

0 commit comments

Comments
 (0)