@@ -62,8 +62,8 @@ impl Referer {
6262 let url = match Url :: parse ( header_value. as_str ( ) ) {
6363 Ok ( url) => url,
6464 Err ( _) => match base_url. try_into ( ) {
65- Ok ( base_url) => base_url. join ( header_value. as_str ( ) . trim ( ) ) . status ( 400 ) ?,
66- Err ( _) => bail ! ( 400 , "Invalid base url provided" ) ,
65+ Ok ( base_url) => base_url. join ( header_value. as_str ( ) . trim ( ) ) . status ( 500 ) ?,
66+ Err ( _) => bail ! ( 500 , "Invalid base url provided" ) ,
6767 } ,
6868 } ;
6969
@@ -94,14 +94,13 @@ impl Referer {
9494 }
9595
9696 /// Set the url.
97- pub fn set_location < U > ( & mut self , location : U )
97+ pub fn set_location < U > ( & mut self , location : U ) -> Result < ( ) , U :: Error >
9898 where
9999 U : TryInto < Url > ,
100100 U :: Error : std:: fmt:: Debug ,
101101 {
102- self . location = location
103- . try_into ( )
104- . expect ( "Could not convert into valid URL" )
102+ self . location = location. try_into ( ) ?;
103+ Ok ( ( ) )
105104 }
106105}
107106
@@ -132,7 +131,7 @@ mod test {
132131 headers. insert ( REFERER , "htt://<nori ate the tag. yum.>" ) ;
133132 let err =
134133 Referer :: from_headers ( Url :: parse ( "https://example.net" ) . unwrap ( ) , headers) . unwrap_err ( ) ;
135- assert_eq ! ( err. status( ) , 400 ) ;
134+ assert_eq ! ( err. status( ) , 500 ) ;
136135 Ok ( ( ) )
137136 }
138137
0 commit comments