regexpPathMatcher function
MatchData?
regexpPathMatcher(
- String path,
- String pattern, {
- RegexpBuilder regexpBuilder = pathToRegexp,
- bool prefix = true,
Implementation
MatchData? regexpPathMatcher(
String path,
String pattern, {
RegexpBuilder regexpBuilder = pathToRegexp,
bool prefix = true,
}) {
final endsWithSlash = pattern.endsWith("/") || pattern.endsWith("/:_(.*)");
final data = regexpBuilder(
pattern,
caseSensitive: false,
prefix: prefix,
);
final regexp = data.regexp;
final parameters = data.parameters;
final match = regexp.matchAsPrefix(
endsWithSlash ? (path.endsWith("/") ? path : "$path/") : path,
);
if (match != null) {
final arguments = extract(parameters, match);
final toPath = pathToFunction(pattern);
return MatchData(
path: toPath(arguments),
arguments: arguments,
);
}
return null;
}