File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -509,7 +509,7 @@ pub(crate) async fn search_handler(
509509 . get ( "query" )
510510 . map ( |q| q. to_string ( ) )
511511 . unwrap_or_else ( || "" . to_string ( ) ) ;
512- let sort_by = params
512+ let mut sort_by = params
513513 . get ( "sort" )
514514 . map ( |q| q. to_string ( ) )
515515 . unwrap_or_else ( || "relevance" . to_string ( ) ) ;
@@ -579,6 +579,20 @@ pub(crate) async fn search_handler(
579579 return Err ( AxumNope :: NoResults ) ;
580580 }
581581
582+ let p = form_urlencoded:: parse ( query_params. as_bytes ( ) ) ;
583+ if let Some ( v) = p
584+ . filter_map ( |( k, v) | {
585+ if & k == "sort" {
586+ Some ( v. to_string ( ) )
587+ } else {
588+ None
589+ }
590+ } )
591+ . next ( )
592+ {
593+ sort_by = v;
594+ } ;
595+
582596 get_search_results ( & mut conn, & config, & query_params) . await ?
583597 } else if !query. is_empty ( ) {
584598 let query_params: String = form_urlencoded:: Serializer :: new ( String :: new ( ) )
@@ -930,7 +944,7 @@ mod tests {
930944 . any ( |el| {
931945 let attributes = el. attributes . borrow ( ) ;
932946 attributes. get ( "selected" ) . is_some ( )
933- && attributes. get ( "value" ) . unwrap ( ) . to_string ( ) == "recent-updates"
947+ && attributes. get ( "value" ) . unwrap ( ) == "recent-updates"
934948 } ) ;
935949 assert ! ( is_target_option_selected) ;
936950
You can’t perform that action at this time.
0 commit comments