match method

Map<String, String>? match(
  1. String path
)

Matches path against this template. Returns the captured params keyed by name, or null when the path does not match — a different segment count, a literal segment mismatch, or a typed param whose value fails its constraint. A template with no params returns an empty map on a match. Audited: 2026-06-12 11:26 EDT

Implementation

Map<String, String>? match(String path) {
  final List<String> parts = _splitPath(path);
  if (parts.length != _segments.length) return null;
  final Map<String, String> params = <String, String>{};
  for (int i = 0; i < _segments.length; i++) {
    if (!_segments[i].accept(parts[i], params)) return null;
  }
  return params;
}