buildRequestURL method

String buildRequestURL(
  1. HttpClient client,
  2. String url, {
  3. Authorization? authorization,
  4. Map<String, String?>? queryParameters,
  5. bool noQueryString = false,
})

Helper to build the request URL.

Implementation

String buildRequestURL(HttpClient client, String url,
    {Authorization? authorization,
    Map<String, String?>? queryParameters,
    bool noQueryString = false}) {
  if (queryParameters != null && queryParameters.isNotEmpty) {
    url = buildURLWithQueryParameters(url, queryParameters,
        removeFragment: true);
  }

  if (authorization != null && authorization.isCredentialResolved) {
    var authorizationURL = authorization.resolvedCredential!.buildURL(url);
    if (authorizationURL != null) return authorizationURL;
  }

  if (noQueryString) {
    url = removeUriQueryString(url).toString();
  }

  return url;
}