@@ -50,20 +50,29 @@ struct DocsCode {
5050 wrapper_end : Option < String > ,
5151}
5252
53- #[ cfg( not( tarpaulin_include) ) ]
54- fn map_ureq_err ( e : ureq:: Error ) -> AppError {
55- AppError :: General ( e. to_string ( ) )
56- }
53+
5754
5855#[ cfg( not( tarpaulin_include) ) ]
56+ #[ cfg( feature = "client" ) ]
5957fn read_input ( input : & str ) -> AppResult < String > {
6058 if input. starts_with ( "http://" ) || input. starts_with ( "https://" ) {
6159 let mut response = ureq:: get ( input)
6260 . call ( )
6361 . map_err ( |e| AppError :: General ( format ! ( "Failed to fetch URL: {}" , e) ) ) ?;
64- response. body_mut ( ) . read_to_string ( ) . map_err ( map_ureq_err)
62+ response. into_string ( ) . map_err ( |e| AppError :: General ( format ! ( "Failed to read HTTP body: {}" , e) ) )
63+ } else {
64+ std:: fs:: read_to_string ( input)
65+ . map_err ( |e| AppError :: General ( format ! ( "Failed to read file: {}" , e) ) )
66+ }
67+ }
68+
69+ #[ cfg( not( tarpaulin_include) ) ]
70+ #[ cfg( not( feature = "client" ) ) ]
71+ fn read_input ( input : & str ) -> AppResult < String > {
72+ if input. starts_with ( "http://" ) || input. starts_with ( "https://" ) {
73+ Err ( AppError :: General ( "Client feature is not compiled, cannot fetch HTTP URLs" . to_string ( ) ) )
6574 } else {
66- fs:: read_to_string ( input)
75+ std :: fs:: read_to_string ( input)
6776 . map_err ( |e| AppError :: General ( format ! ( "Failed to read file: {}" , e) ) )
6877 }
6978}
0 commit comments