@@ -215,13 +215,6 @@ impl FilterBodyActionItem {
215215 TextAction :: Append => TextFilterAction :: Append ,
216216 TextAction :: Prepend => TextFilterAction :: Prepend ,
217217 TextAction :: Replace => TextFilterAction :: Replace ,
218- _ => {
219- log:: warn!(
220- "unsupported text body filter action: {:?}, you may need to update your agent or module" ,
221- text_body_filter. action
222- ) ;
223- return None ;
224- }
225218 } ,
226219 text_body_filter. content ,
227220 ) ) ) ,
@@ -267,7 +260,7 @@ mod tests {
267260 } ;
268261
269262 use super :: * ;
270- use crate :: api:: HTMLBodyFilter ;
263+ use crate :: api:: { HTMLBodyFilter , HTMLBodyFilterInnerLegacy } ;
271264
272265 #[ test]
273266 pub fn test_filter_gzip ( ) {
@@ -288,15 +281,14 @@ mod tests {
288281 ] ;
289282
290283 let mut filter = FilterBodyAction :: new (
291- vec ! [ BodyFilter :: HTML ( HTMLBodyFilter {
292- action: "prepend_child" . to_string( ) ,
284+ vec ! [ BodyFilter :: HTML ( HTMLBodyFilter :: PrependLegacy ( HTMLBodyFilterInnerLegacy {
293285 element_tree: vec![ "html" . to_string( ) , "body" . to_string( ) ] ,
294286 css_selector: Some ( "" . to_string( ) ) ,
295287 value: "<p>This is as test</p>" . to_string( ) ,
296288 id: Some ( "test" . to_string( ) ) ,
297289 target_hash: Some ( "target_hash" . to_string( ) ) ,
298290 inner_value: None ,
299- } ) ] ,
291+ } ) ) ] ,
300292 & headers,
301293 None ,
302294 Vec :: new ( ) ,
@@ -343,15 +335,14 @@ mod tests {
343335 ] ;
344336
345337 let mut filter = FilterBodyAction :: new (
346- vec ! [ BodyFilter :: HTML ( HTMLBodyFilter {
347- action: "prepend_child" . to_string( ) ,
338+ vec ! [ BodyFilter :: HTML ( HTMLBodyFilter :: PrependLegacy ( HTMLBodyFilterInnerLegacy {
348339 element_tree: vec![ "html" . to_string( ) , "body" . to_string( ) ] ,
349340 css_selector: Some ( "" . to_string( ) ) ,
350341 value: "<p>This is as test</p>" . to_string( ) ,
351342 id: Some ( "test" . to_string( ) ) ,
352343 target_hash: Some ( "target_hash" . to_string( ) ) ,
353344 inner_value: None ,
354- } ) ] ,
345+ } ) ) ] ,
355346 & headers,
356347 None ,
357348 Vec :: new ( ) ,
@@ -398,15 +389,14 @@ mod tests {
398389 ] ;
399390
400391 let mut filter = FilterBodyAction :: new (
401- vec ! [ BodyFilter :: HTML ( HTMLBodyFilter {
402- action: "prepend_child" . to_string( ) ,
392+ vec ! [ BodyFilter :: HTML ( HTMLBodyFilter :: PrependLegacy ( HTMLBodyFilterInnerLegacy {
403393 element_tree: vec![ "html" . to_string( ) , "body" . to_string( ) ] ,
404394 css_selector: Some ( "" . to_string( ) ) ,
405395 value: "<p>This is as test</p>" . to_string( ) ,
406396 id: Some ( "test" . to_string( ) ) ,
407397 target_hash: Some ( "target_hash" . to_string( ) ) ,
408398 inner_value: None ,
409- } ) ] ,
399+ } ) ) ] ,
410400 & headers,
411401 None ,
412402 Vec :: new ( ) ,
@@ -460,24 +450,22 @@ mod tests {
460450 pub fn test_replace ( ) {
461451 let mut filter = FilterBodyAction :: new (
462452 vec ! [
463- BodyFilter :: HTML ( HTMLBodyFilter {
464- action: "append_child" . to_string( ) ,
453+ BodyFilter :: HTML ( HTMLBodyFilter :: AppendLegacy ( HTMLBodyFilterInnerLegacy {
465454 element_tree: vec![ "html" . to_string( ) , "head" . to_string( ) ] ,
466455 css_selector: Some ( r#"meta[name="description"]"# . to_string( ) ) ,
467456 value: "<meta name=\" description\" content=\" New Description\" />" . to_string( ) ,
468457 id: Some ( "test" . to_string( ) ) ,
469458 target_hash: Some ( "target_hash" . to_string( ) ) ,
470459 inner_value: None ,
471- } ) ,
472- BodyFilter :: HTML ( HTMLBodyFilter {
473- action: "replace" . to_string( ) ,
460+ } ) ) ,
461+ BodyFilter :: HTML ( HTMLBodyFilter :: ReplaceLegacy ( HTMLBodyFilterInnerLegacy {
474462 element_tree: vec![ "html" . to_string( ) , "head" . to_string( ) , "meta" . to_string( ) ] ,
475463 css_selector: Some ( r#"meta[name="description"]"# . to_string( ) ) ,
476464 value: "<meta name=\" description\" content=\" New Description\" />" . to_string( ) ,
477465 id: Some ( "test" . to_string( ) ) ,
478466 target_hash: Some ( "target_hash" . to_string( ) ) ,
479467 inner_value: None ,
480- } ) ,
468+ } ) ) ,
481469 ] ,
482470 & [ ] ,
483471 None ,
@@ -500,24 +488,22 @@ mod tests {
500488 pub fn test_append ( ) {
501489 let mut filter = FilterBodyAction :: new (
502490 vec ! [
503- BodyFilter :: HTML ( HTMLBodyFilter {
504- action: "append_child" . to_string( ) ,
491+ BodyFilter :: HTML ( HTMLBodyFilter :: AppendLegacy ( HTMLBodyFilterInnerLegacy {
505492 element_tree: vec![ "html" . to_string( ) , "head" . to_string( ) ] ,
506493 css_selector: Some ( r#"meta[name="description"]"# . to_string( ) ) ,
507494 value: "<meta name=\" description\" content=\" New Description\" />" . to_string( ) ,
508495 id: Some ( "test" . to_string( ) ) ,
509496 target_hash: Some ( "target_hash" . to_string( ) ) ,
510497 inner_value: None ,
511- } ) ,
512- BodyFilter :: HTML ( HTMLBodyFilter {
513- action: "replace" . to_string( ) ,
498+ } ) ) ,
499+ BodyFilter :: HTML ( HTMLBodyFilter :: ReplaceLegacy ( HTMLBodyFilterInnerLegacy {
514500 element_tree: vec![ "html" . to_string( ) , "head" . to_string( ) , "meta" . to_string( ) ] ,
515501 css_selector: Some ( r#"meta[name="description"]"# . to_string( ) ) ,
516502 value: "<meta name=\" description\" content=\" New Description\" />" . to_string( ) ,
517503 id: Some ( "test" . to_string( ) ) ,
518504 target_hash: Some ( "target_hash" . to_string( ) ) ,
519505 inner_value: None ,
520- } ) ,
506+ } ) ) ,
521507 ] ,
522508 & [ ] ,
523509 None ,
@@ -536,15 +522,14 @@ mod tests {
536522 #[ test]
537523 pub fn test_prepend ( ) {
538524 let mut filter = FilterBodyAction :: new (
539- vec ! [ BodyFilter :: HTML ( HTMLBodyFilter {
540- action: "prepend_child" . to_string( ) ,
525+ vec ! [ BodyFilter :: HTML ( HTMLBodyFilter :: PrependLegacy ( HTMLBodyFilterInnerLegacy {
541526 element_tree: vec![ "html" . to_string( ) , "body" . to_string( ) ] ,
542527 css_selector: Some ( "" . to_string( ) ) ,
543528 value: "<p>This is as test</p>" . to_string( ) ,
544529 id: Some ( "test" . to_string( ) ) ,
545530 target_hash: Some ( "target_hash" . to_string( ) ) ,
546531 inner_value: None ,
547- } ) ] ,
532+ } ) ) ] ,
548533 & [ ] ,
549534 None ,
550535 Vec :: new ( ) ,
@@ -567,15 +552,14 @@ mod tests {
567552 #[ test]
568553 pub fn test_description_2 ( ) {
569554 let mut filter = FilterBodyAction :: new (
570- vec ! [ BodyFilter :: HTML ( HTMLBodyFilter {
571- action: "replace" . to_string( ) ,
555+ vec ! [ BodyFilter :: HTML ( HTMLBodyFilter :: ReplaceLegacy ( HTMLBodyFilterInnerLegacy {
572556 element_tree: vec![ "html" . to_string( ) , "head" . to_string( ) , "meta" . to_string( ) ] ,
573557 css_selector: Some ( r#"meta[property="og:description"]"# . to_string( ) ) ,
574558 value: r#"<meta property="og:description" content="New Description" />"# . to_string( ) ,
575559 id: Some ( "test" . to_string( ) ) ,
576560 target_hash: Some ( "target_hash" . to_string( ) ) ,
577561 inner_value: None ,
578- } ) ] ,
562+ } ) ) ] ,
579563 & [ ] ,
580564 None ,
581565 Vec :: new ( ) ,
@@ -593,15 +577,14 @@ mod tests {
593577 #[ test]
594578 pub fn test_capture_buffered ( ) {
595579 let mut filter = FilterBodyAction :: new (
596- vec ! [ BodyFilter :: HTML ( HTMLBodyFilter {
597- action: "replace" . to_string( ) ,
580+ vec ! [ BodyFilter :: HTML ( HTMLBodyFilter :: ReplaceLegacy ( HTMLBodyFilterInnerLegacy {
598581 element_tree: vec![ "html" . to_string( ) , "body" . to_string( ) , "h2" . to_string( ) ] ,
599582 css_selector: None ,
600583 value: r#"<h2>@var1</h2>"# . to_string( ) ,
601584 id: Some ( "test" . to_string( ) ) ,
602585 target_hash: Some ( "target_hash" . to_string( ) ) ,
603586 inner_value: None ,
604- } ) ] ,
587+ } ) ) ] ,
605588 & [ ] ,
606589 None ,
607590 vec ! [ (
0 commit comments