VVETADYZOWCU4IYTJVLKZR2X5HWH6FUKIVLWQNQIAUG4LKTONL6QC
let is_case_sensitive: bool = if let Ok(case_sensitive) = dotenvy::var("CASE_SENSITIVE") {
if let Ok(lb) = case_sensitive.parse::<LexicalBool>() {
let is_regex: bool = if let Ok(regex) = dotenvy::var("USE_REGEX") {
if let Ok(lb) = regex.parse::<LexicalBool>() {
) -> Filter {
Filter {
is_regex: bool,
) -> Result<Filter, &'static str> {
let include_plain: Vec<String>;
let exclude_plain: Vec<String>;
let mut include_regex: Vec<Regex>;
let mut exclude_regex: Vec<Regex>;
if is_regex {
include_plain = vec![];
exclude_plain = vec![];
include_regex = vec![];
exclude_regex = vec![];
for i in include {
let Ok(re) = Regex::new(i.as_str()) else {
return Err("Invalid Regex");
};
include_regex.push(re);
}
for i in exclude {
let Ok(re) = Regex::new(i.as_str()) else {
return Err("Invalid Regex");
};
exclude_regex.push(re);
}
} else {
include_plain = include;
exclude_plain = exclude;
include_regex = vec![];
exclude_regex = vec![];
}
Ok(Filter {
if !settings.include_regex.is_empty()
&& settings
.include_regex
.into_iter()
.filter(|x| x.is_match(&content))
.collect::<Vec<Regex>>()
.is_empty()
{
return false;
}
if !settings
.exclude_regex
.into_iter()
.filter(|x| x.is_match(&content))
.collect::<Vec<Regex>>()
.is_empty()
{
return false;
}
regex = { version = "1.10" }