Skip to content

Commit

Permalink
v0.33.1, fix #6
Browse files Browse the repository at this point in the history
Signed-off-by: Vrtgs <[email protected]>
  • Loading branch information
Vrtgs committed Aug 24, 2024
1 parent 3da519d commit 5f5a6f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion thirtyfour/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thirtyfour"
version = "0.33.0"
version = "0.33.1"
authors = ["Steve Pryde <[email protected]>", "Vrtgs"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 2 additions & 0 deletions thirtyfour/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ pub enum WebDriverError {
InsecureCertificate(WebDriverErrorInfo),
#[error("An argument passed to the WebDriver server was invalid: {0}")]
InvalidArgument(WebDriverErrorInfo),
#[error("An argument passed to the WebDriver server was invalid: {0}")]
InvalidUrl(url::ParseError),
#[error("Invalid cookie domain: {0}")]
InvalidCookieDomain(WebDriverErrorInfo),
#[error("The element is in an invalid state: {0}")]
Expand Down
17 changes: 12 additions & 5 deletions thirtyfour/src/session/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tokio::fs::File;
use tokio::io::AsyncWriteExt;
use tokio::runtime::RuntimeFlavor;
use tokio::sync::OnceCell;
use url::Url;
use url::{ParseError, Url};

use crate::action_chain::ActionChain;
use crate::common::command::{Command, FormatRequestData};
Expand Down Expand Up @@ -190,10 +190,17 @@ impl SessionHandle {
/// # }
/// ```
pub async fn goto(&self, url: impl IntoArcStr) -> WebDriverResult<()> {
let mut url = url.into();
if !url.starts_with("http") {
url = format!("https://{url}").into();
}
let url = url.into();

let parse_url = |url: Arc<str>| Url::parse(&url).map(|_| url);
let url = parse_url(url.clone())
.or_else(|e| match e {
ParseError::RelativeUrlWithoutBase => {
parse_url(("https://".to_string() + &*url).into())
}
e => Err(e),
})
.map_err(WebDriverError::InvalidUrl)?;
self.cmd(Command::NavigateTo(url)).await?;
Ok(())
}
Expand Down

0 comments on commit 5f5a6f7

Please sign in to comment.