resolveNetworkCaptureRule static method
Returns the first CxNetworkCaptureRule whose url exactly matches or
whose urlPattern regex matches url. Returns null if no rule matches.
When a rule has both CxNetworkCaptureRule.url and
CxNetworkCaptureRule.urlPattern set, the exact url match is tried
first and urlPattern is only checked if url does not match.
Implementation
static CxNetworkCaptureRule? resolveNetworkCaptureRule(
String url, List<CxNetworkCaptureRule> rules) {
for (final rule in rules) {
// Within a single rule, url and urlPattern act as OR conditions:
// the rule fires if either matcher succeeds. url (exact) is tried first.
if (rule.url != null && rule.url == url) return rule;
if (rule.compiledPattern != null && rule.compiledPattern!.hasMatch(url)) {
return rule;
}
}
return null;
}