Lightning browser with I2P configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
817 B

package org.purplei2p.lightning.favicon;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
/**
* Simple utils for favicon fetching.
*/
public class FaviconUtils {
@Nullable
public static Uri safeUri(@NonNull String url) {
if (TextUtils.isEmpty(url)) {
return null;
}
Uri uri = Uri.parse(url);
if (TextUtils.isEmpty(uri.getScheme()) || TextUtils.isEmpty(uri.getHost())) {
return null;
}
return uri;
}
static void assertUriSafe(@Nullable Uri uri) {
if (uri == null || TextUtils.isEmpty(uri.getScheme()) || TextUtils.isEmpty(uri.getHost())) {
throw new RuntimeException("Unsafe uri provided");
}
}
}