File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[package ]
22name = " thirtyfour"
3- version = " 0.33.0 "
3+ version = " 0.33.1 "
44authors = [" Steve Pryde <steve@stevepryde.com>" , " Vrtgs" ]
55edition = " 2021"
66license = " MIT OR Apache-2.0"
Original file line number Diff line number Diff 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}" ) ]
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use tokio::fs::File;
1010use tokio:: io:: AsyncWriteExt ;
1111use tokio:: runtime:: RuntimeFlavor ;
1212use tokio:: sync:: OnceCell ;
13- use url:: Url ;
13+ use url:: { ParseError , Url } ;
1414
1515use crate :: action_chain:: ActionChain ;
1616use 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 }
You can’t perform that action at this time.
0 commit comments