message: added new filter
diff: use crate::config::CONFIGURATION;
  use crate::utils::get_url_path_length;
  use crate::FeroxResponse;
  +use regex::Regex;
  use std::any::Any;
  use std::fmt::Debug;
  @@ -237,6 +238,50 @@ impl FeroxFilter for SizeFilter {
  }
  }
  +/// Simple implementor of FeroxFilter; used to filter out responses based on a given regular
  +/// expression; specified using -X|--filter-regex
  +#[derive(Debug)]
  +pub struct RegexFilter {
  + /// Regular expression to be applied to the response body for filtering, compiled
  + pub compiled: Regex,
  +
  + /// Regular expression as passed in on the command line, not compiled
  + pub raw_string: String,
  +}
  +
  +/// implementation of FeroxFilter for RegexFilter
  +impl FeroxFilter for RegexFilter {
  + /// Check `expression` against the response body, if the expression matches, the response
  + /// should be filtered out
  + fn should_filter_response(&self, response: &FeroxResponse) -> bool {
  + log::trace!("enter: should_filter_response({:?} {})", self, response);
  +
  + let result = self.compiled.is_match(response.text());
  +
  + log::trace!("exit: should_filter_response -> {}", result);
  +
  + result
  + }
  +
  + /// Compare one SizeFilter to another
  + fn box_eq(&self, other: &dyn Any) -> bool {
  + other.downcast_ref::<Self>().map_or(false, |a| self == a)
  + }
  +
  + /// Return self as Any for dynamic dispatch purposes
  + fn as_any(&self) -> &dyn Any {
  + self
  + }
  +}
  +
  +/// PartialEq implementation for RegexFilter
  +impl PartialEq for RegexFilter {
  + /// Simple comparison of the raw string passed in via the command line
  + fn eq(&self, other: &RegexFilter) -> bool {
  + self.raw_string == other.raw_string
  + }
  +}
  +
  #[cfg(test)]
  mod tests {
  use super::*;
  @@ -288,4 +333,21 @@ mod tests {
  filter
  );
  }
  +
  + #[test]
  + /// just a simple test to increase code coverage by hitting as_any and the inner value
  + fn regex_filter_as_any() {
  + let raw = r".*\.txt$";
  + let compiled = Regex::new(raw).unwrap();
  + let filter = RegexFilter {
  + compiled,
  + raw_string: raw.to_string(),
  + };
  +
  + assert_eq!(filter.raw_string, r".*\.txt$");
  + assert_eq!(
  + *filter.as_any().downcast_ref::<RegexFilter>().unwrap(),
  + filter
  + );
  + }
  }
  