pathExists method
Checks if the given url matches with the given filters.
url
must conform to uri parsing.
Implementation
bool pathExists(
String url,
RegExp pathPattern, {
Map<String, String?>? queryParams,
}) {
if (!pathPattern.hasMatch(url)) return false;
var hasMatch = true;
final uri = Uri.parse(url);
if (queryParams != null) {
for (final entry in queryParams.entries) {
hasMatch &= uri.queryParameters.containsKey(entry.key);
if (entry.value != null) {
hasMatch &= uri.queryParameters[entry.key] == entry.value;
}
if (!hasMatch) break;
}
}
return hasMatch;
}