@Nullable
  public static URL uriToUrl(@PropagatesNullable @Nullable Uri uri) {
    if (uri == null) {
      return null;
    }

    try {
      return new URL(uri.toString());
    } catch (java.net.MalformedURLException e) {
      // This should never happen since we got a valid uri
      throw new RuntimeException(e);
    }
  }
Convert android.net.Uri to java.net.URL as necessary for some networking APIs.

@param uri uri to convert
@return url pointing to the same resource as uri
fbcore/src/main/java/com/facebook/common/util/UriUtil.java