requestURL property

String requestURL

The full URL of this request.

This value is derived from baseURL, path, and query.

Implementation

String get requestURL {
  if (path == null || baseURL == null) {
    throw StateError("TestRequest must have non-null path and baseURL.");
  }

  var actualPath = path!;
  while (actualPath.startsWith("/")) {
    actualPath = actualPath.substring(1);
  }

  var url = _baseUrl.resolve(actualPath).toString();
  if ((query?.length ?? 0) > 0) {
    final pairs = query!.keys.map((key) {
      final val = query![key];
      if (val == null || val == true) {
        return "$key";
      } else {
        return "$key=${Uri.encodeComponent("$val")}";
      }
    });

    url = "$url?${pairs.join("&")}";
  }

  return url;
}