describeUrl static method

String describeUrl(
  1. Uri uri
)

https://host/path?key=*&other=*: the query's values are replaced, its keys kept; user info and fragment dropped.

Implementation

static String describeUrl(Uri uri) {
  final port = uri.hasPort ? ':${uri.port}' : '';
  final keys = uri.hasQuery ? [for (final p in uri.query.split('&')) p.split('=').first] : const <String>[];
  final query = keys.where((k) => k.isNotEmpty).map((k) => '$k=*').join('&');
  return '${uri.scheme}://${uri.host}$port${uri.path}${query.isEmpty ? '' : '?$query'}';
}