Skip to content

Commit 4c23ff9

Browse files
Update src/repositories/monitor.rs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent a946237 commit 4c23ff9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/repositories/monitor.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,17 @@ impl<
7979
continue;
8080
}
8181

82+
let has_parens = |sig: &str| {
83+
let sig = sig.trim();
84+
match (sig.find('('), sig.rfind(')')) {
85+
(Some(open), Some(close)) if open < close && close == sig.len() - 1 => true,
86+
_ => false,
87+
}
88+
};
89+
8290
// Validate function signatures
8391
for func in &monitor.match_conditions.functions {
84-
if !func.signature.contains('(') || !func.signature.contains(')') {
92+
if !has_parens(&func.signature) {
8593
validation_errors.push(format!(
8694
"Monitor '{}' has invalid function signature '{}' for {} network '{}' \
8795
(expected format: 'functionName(type1,type2)')",
@@ -92,7 +100,7 @@ impl<
92100

93101
// Validate event signatures
94102
for event in &monitor.match_conditions.events {
95-
if !event.signature.contains('(') || !event.signature.contains(')') {
103+
if !has_parens(&event.signature) {
96104
validation_errors.push(format!(
97105
"Monitor '{}' has invalid event signature '{}' for {} network '{}' \
98106
(expected format: 'EventName(type1,type2)')",

0 commit comments

Comments
 (0)