match method
Matches path against registered routes.
Accepts a full URL location including optional query string and hash fragment.
Matches route patterns against the cleaned path while extracting query parameters
into BloomRouteMatch.query and BloomRouteMatch.queryAll, and hash fragments into
BloomRouteMatch.fragment. If trailing is true, trailing slashes are removed
before evaluation. Returns a BloomRouteMatch if a route matches or if notFound
is configured; returns null otherwise.
Implementation
BloomRouteMatch? match(String path) {
var clean = path.split('?').first.split('#').first;
if (trailing && clean.length > 1 && clean.endsWith('/')) {
clean = clean.substring(0, clean.length - 1);
}
final query = parseQueryString(path);
final queryAll = parseQueryStringAll(path);
final fragment = parseFragment(path);
return _matchList(
routes,
clean,
query: query,
queryAll: queryAll,
fragment: fragment,
);
}