Slightly edit module matching logic for conciseness/clarity
Also allow using identifier names directly as shorthand, without surrounding .{ ... }
This commit is contained in:
parent
99ec0ff6b0
commit
e06bbc4e73
|
@ -716,7 +716,11 @@ where
|
||||||
.map(|match_test| {
|
.map(|match_test| {
|
||||||
let mut match_split_dot = match_test.split('.');
|
let mut match_split_dot = match_test.split('.');
|
||||||
|
|
||||||
let match_module = match_split_dot.next().unwrap_or("");
|
let match_module = if match_test.contains('.') {
|
||||||
|
match_split_dot.next().unwrap_or("")
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
let match_names = match_split_dot.next().map(|names| {
|
let match_names = match_split_dot.next().map(|names| {
|
||||||
let names = names.replace(&['{', '}'][..], "");
|
let names = names.replace(&['{', '}'][..], "");
|
||||||
|
@ -733,29 +737,19 @@ where
|
||||||
scripts
|
scripts
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|script| -> bool {
|
.filter(|script| -> bool {
|
||||||
match_tests.iter().any(|(match_module, match_names)| {
|
match_tests.iter().any(|(module, names)| {
|
||||||
let matches_name = || {
|
let matched_module = module == &"" || script.module.contains(module);
|
||||||
matches!(match_names, Some(match_names) if match_names
|
|
||||||
.iter()
|
|
||||||
.any(|name| if exact_match {
|
|
||||||
name == &script.name
|
|
||||||
} else {
|
|
||||||
script.name.contains(name)
|
|
||||||
}
|
|
||||||
))
|
|
||||||
};
|
|
||||||
|
|
||||||
if *match_module == script.module || script.module.contains(match_module) {
|
let matched_name = matches!(names, Some(names) if names
|
||||||
if match_names.is_some() {
|
.iter()
|
||||||
matches_name()
|
.any(|name| if exact_match {
|
||||||
|
name == &script.name
|
||||||
} else {
|
} else {
|
||||||
true
|
script.name.contains(name)
|
||||||
}
|
}
|
||||||
} else if match_names.is_some() && match_module == &"" {
|
));
|
||||||
matches_name()
|
|
||||||
} else {
|
matched_module && matched_name
|
||||||
false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect::<Vec<Script>>()
|
.collect::<Vec<Script>>()
|
||||||
|
|
Loading…
Reference in New Issue