keyMatch2 function
keyMatch2 determines whether key1
matches the pattern of key2
(similar to RESTful path),
key2
can contain a .
For example, "/foo/bar" matches "/foo/", "/resource1" matches "/:resource"
Implementation
bool keyMatch2(String key1, String key2) {
key2 = key2.replaceAll('/*', '/.*');
final re = RegExp(':[^/]+');
key2 = key2.replaceAll(re, '[^/]+');
return regexMatch(key1, '^' + key2 + '\$');
}