dvRouteShape function

String dvRouteShape(
  1. String path
)

A route reduced to what matching sees: parameter names and a trailing slash do not make two routes different.

/users/:id and /users/:slug have the same shape, so declaring both is declaring one route twice.

Implementation

String dvRouteShape(String path) {
  final List<String> segments = _segments(path)
      .map(
        (String s) => s.startsWith(':')
            ? ':'
            : s.startsWith('*')
            ? '*'
            : s,
      )
      .toList();
  return '/${segments.join('/')}';
}