@@ -45,6 +45,7 @@ impl From<JSONEngineUrls> for SearchEngineUrls {
4545 search : urls. search . unwrap_or_default ( ) . into ( ) ,
4646 suggestions : urls. suggestions . map ( |suggestions| suggestions. into ( ) ) ,
4747 trending : urls. trending . map ( |trending| trending. into ( ) ) ,
48+ search_form : urls. search_form . map ( |search_form| search_form. into ( ) ) ,
4849 }
4950 }
5051}
@@ -63,7 +64,13 @@ impl SearchEngineUrls {
6364 if let Some ( trending_url) = & preferred. trending {
6465 match & mut self . trending {
6566 Some ( trend) => trend. merge ( trending_url) ,
66- None => self . suggestions = Some ( trending_url. clone ( ) . into ( ) ) ,
67+ None => self . trending = Some ( trending_url. clone ( ) . into ( ) ) ,
68+ } ;
69+ }
70+ if let Some ( search_form_url) = & preferred. search_form {
71+ match & mut self . search_form {
72+ Some ( search_form) => search_form. merge ( search_form_url) ,
73+ None => self . search_form = Some ( search_form_url. clone ( ) . into ( ) ) ,
6774 } ;
6875 }
6976 }
@@ -296,6 +303,7 @@ mod tests {
296303 } ) ,
297304 suggestions : None ,
298305 trending : None ,
306+ search_form : None ,
299307 } ,
300308 } ,
301309 & JSONEngineVariant {
@@ -332,7 +340,8 @@ mod tests {
332340 search_term_param_name: None ,
333341 } ,
334342 suggestions: None ,
335- trending: None
343+ trending: None ,
344+ search_form: None
336345 }
337346 }
338347 )
@@ -386,6 +395,17 @@ mod tests {
386395 } ] ) ,
387396 search_term_param_name : None ,
388397 } ) ,
398+ search_form : Some ( JSONEngineUrl {
399+ base : Some ( "https://example.com/search_form" . to_string ( ) ) ,
400+ method : Some ( crate :: JSONEngineMethod :: Get ) ,
401+ params : Some ( vec ! [ SearchUrlParam {
402+ name: "search-form-name" . to_string( ) ,
403+ value: Some ( "search-form-value" . to_string( ) ) ,
404+ enterprise_value: None ,
405+ experiment_config: None ,
406+ } ] ) ,
407+ search_term_param_name : None ,
408+ } ) ,
389409 } ,
390410 } ) ;
391411
@@ -461,7 +481,18 @@ mod tests {
461481 experiment_config: None ,
462482 } ] ,
463483 search_term_param_name: None ,
464- } )
484+ } ) ,
485+ search_form: Some ( SearchEngineUrl {
486+ base: "https://example.com/search_form" . to_string( ) ,
487+ method: "GET" . to_string( ) ,
488+ params: vec![ SearchUrlParam {
489+ name: "search-form-name" . to_string( ) ,
490+ value: Some ( "search-form-value" . to_string( ) ) ,
491+ enterprise_value: None ,
492+ experiment_config: None ,
493+ } ] ,
494+ search_term_param_name: None ,
495+ } ) ,
465496 }
466497 }
467498 )
@@ -514,6 +545,17 @@ mod tests {
514545 } ] ) ,
515546 search_term_param_name : Some ( "trend" . to_string ( ) ) ,
516547 } ) ,
548+ search_form : Some ( JSONEngineUrl {
549+ base : Some ( "https://example.com/search_form" . to_string ( ) ) ,
550+ method : Some ( crate :: JSONEngineMethod :: Get ) ,
551+ params : Some ( vec ! [ SearchUrlParam {
552+ name: "search-form-name" . to_string( ) ,
553+ value: Some ( "search-form-value" . to_string( ) ) ,
554+ enterprise_value: None ,
555+ experiment_config: None ,
556+ } ] ) ,
557+ search_term_param_name : None ,
558+ } ) ,
517559 } ) ,
518560 sub_variants : vec ! [ ] ,
519561 } ,
@@ -565,7 +607,18 @@ mod tests {
565607 experiment_config: None ,
566608 } ] ,
567609 search_term_param_name: Some ( "trend" . to_string( ) ) ,
568- } )
610+ } ) ,
611+ search_form: Some ( SearchEngineUrl {
612+ base: "https://example.com/search_form" . to_string( ) ,
613+ method: "GET" . to_string( ) ,
614+ params: vec![ SearchUrlParam {
615+ name: "search-form-name" . to_string( ) ,
616+ value: Some ( "search-form-value" . to_string( ) ) ,
617+ enterprise_value: None ,
618+ experiment_config: None ,
619+ } ] ,
620+ search_term_param_name: None ,
621+ } ) ,
569622 }
570623 }
571624 )
@@ -618,6 +671,17 @@ mod tests {
618671 } ] ) ,
619672 search_term_param_name : Some ( "trend" . to_string ( ) ) ,
620673 } ) ,
674+ search_form : Some ( JSONEngineUrl {
675+ base : Some ( "https://example.com/search-form-variant" . to_string ( ) ) ,
676+ method : Some ( crate :: JSONEngineMethod :: Get ) ,
677+ params : Some ( vec ! [ SearchUrlParam {
678+ name: "search-form-variant" . to_string( ) ,
679+ value: Some ( "search form variant" . to_string( ) ) ,
680+ enterprise_value: None ,
681+ experiment_config: None ,
682+ } ] ) ,
683+ search_term_param_name : None ,
684+ } ) ,
621685 } ) ,
622686 // This would be the list of sub-variants for this part of the
623687 // configuration, however it is not used as the actual sub-variant
@@ -667,6 +731,17 @@ mod tests {
667731 } ] ) ,
668732 search_term_param_name : Some ( "subtrend" . to_string ( ) ) ,
669733 } ) ,
734+ search_form : Some ( JSONEngineUrl {
735+ base : Some ( "https://example.com/search-form-subvariant" . to_string ( ) ) ,
736+ method : Some ( crate :: JSONEngineMethod :: Get ) ,
737+ params : Some ( vec ! [ SearchUrlParam {
738+ name: "search-form-subvariant" . to_string( ) ,
739+ value: Some ( "search form subvariant" . to_string( ) ) ,
740+ enterprise_value: None ,
741+ experiment_config: None ,
742+ } ] ) ,
743+ search_term_param_name : None ,
744+ } ) ,
670745 } ) ,
671746 sub_variants : vec ! [ ] ,
672747 } ) ,
@@ -717,7 +792,18 @@ mod tests {
717792 experiment_config: None ,
718793 } ] ,
719794 search_term_param_name: Some ( "subtrend" . to_string( ) ) ,
720- } )
795+ } ) ,
796+ search_form: Some ( SearchEngineUrl {
797+ base: "https://example.com/search-form-subvariant" . to_string( ) ,
798+ method: "GET" . to_string( ) ,
799+ params: vec![ SearchUrlParam {
800+ name: "search-form-subvariant" . to_string( ) ,
801+ value: Some ( "search form subvariant" . to_string( ) ) ,
802+ enterprise_value: None ,
803+ experiment_config: None ,
804+ } ] ,
805+ search_term_param_name: None ,
806+ } ) ,
721807 }
722808 }
723809 )
0 commit comments