code: public static String getServiceClientBaseAddress(final URI address, final boolean usePathStyleUris)
              throws URISyntaxException {
          if (address == null) {
              return null;
          }
  
          if (usePathStyleUris) {
              final String[] pathSegments = address.getRawPath().split("/");
  
              if (pathSegments.length < 2) {
                  final String error = String.format(SR.PATH_STYLE_URI_MISSING_ACCOUNT_INFORMATION);
                  throw new IllegalArgumentException(error);
              }
  
              final StringBuilder completeAddress = new StringBuilder(new URI(address.getScheme(),
                      address.getAuthority(), null, null, null).toString());
              completeAddress.append("/");
              completeAddress.append(Utility.trimEnd(pathSegments[1], '/'));
  
              return completeAddress.toString();
          }
          else {
              return new URI(address.getScheme(), address.getAuthority(), null, null, null).toString();
          }
      }
docs: Get the service client address from a complete Uri.
  
  @param address
  Complete address of the resource.
  @param usePathStyleUris
  a value indicating if the address is a path style uri.
  @return the service client address from a complete Uri.
  @throws URISyntaxException