File tree 1 file changed +16
-2
lines changed
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(
509
509
. get ( "query" )
510
510
. map ( |q| q. to_string ( ) )
511
511
. unwrap_or_else ( || "" . to_string ( ) ) ;
512
- let sort_by = params
512
+ let mut sort_by = params
513
513
. get ( "sort" )
514
514
. map ( |q| q. to_string ( ) )
515
515
. unwrap_or_else ( || "relevance" . to_string ( ) ) ;
@@ -579,6 +579,20 @@ pub(crate) async fn search_handler(
579
579
return Err ( AxumNope :: NoResults ) ;
580
580
}
581
581
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
+
582
596
get_search_results ( & mut conn, & config, & query_params) . await ?
583
597
} else if !query. is_empty ( ) {
584
598
let query_params: String = form_urlencoded:: Serializer :: new ( String :: new ( ) )
@@ -930,7 +944,7 @@ mod tests {
930
944
. any ( |el| {
931
945
let attributes = el. attributes . borrow ( ) ;
932
946
attributes. get ( "selected" ) . is_some ( )
933
- && attributes. get ( "value" ) . unwrap ( ) . to_string ( ) == "recent-updates"
947
+ && attributes. get ( "value" ) . unwrap ( ) == "recent-updates"
934
948
} ) ;
935
949
assert ! ( is_target_option_selected) ;
936
950
You can’t perform that action at this time.
0 commit comments