File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ use rust_embed::RustEmbed;
1717use serde:: { Deserialize , Deserializer , Serialize , Serializer } ;
1818use serde_json:: Value ;
1919use serde_json_path:: { JsonPath , JsonPathExt } ;
20- use std:: collections:: { HashMap , HashSet } ;
20+ use std:: collections:: HashSet ;
2121use std:: env;
2222use std:: io:: { Read , Write } ;
2323use std:: string:: ToString ;
@@ -890,15 +890,10 @@ pub async fn parse_post(post: &Value) -> Post {
890890
891891/// Grab a query parameter from a url
892892pub fn param ( path : & str , value : & str ) -> Option < String > {
893- Some (
894- Url :: parse ( format ! ( "https://libredd.it/{path}" ) . as_str ( ) )
895- . ok ( ) ?
896- . query_pairs ( )
897- . into_owned ( )
898- . collect :: < HashMap < _ , _ > > ( )
899- . get ( value) ?
900- . clone ( ) ,
901- )
893+ let query = path. splitn ( 2 , '?' ) . nth ( 1 ) . unwrap_or_default ( ) ;
894+ url:: form_urlencoded:: parse ( query. as_bytes ( ) )
895+ . find ( |( k, _) | k == value)
896+ . map ( |( _, v) | v. into_owned ( ) )
902897}
903898
904899/// Retrieve the value of a setting by name
You can’t perform that action at this time.
0 commit comments