match method
Implementation
bool match(String rawActualUrl) {
/// Clean up urls, remove query params
String templateUrlPath = path.split('?').first;
String actualUrlPath = rawActualUrl.split('?').first;
/// Create a regular expression to find path parameters in the template
final RegExp pathParamPattern = RegExp(r'{([^}]+)}');
/// Create a regular expression to capture the corresponding values in the actual URL
String regexPattern = templateUrlPath.replaceAllMapped(
pathParamPattern,
(match) => r'([^/?]+)',
);
/// Add start and end
/// Same as '^$regexPattern\$' => '^something$'
regexPattern = r'^' + regexPattern + r'$';
/// Check if url match
return RegExp(regexPattern).hasMatch(actualUrlPath);
}