Add support for data: Uri scheme to RCTImageView (e.g. base64-encoded images)

Summary: ImageRequestHelper was not handling data: scheme correctly, which resulted in images failing to load. This diff is fixing it by considering \"data:\" as a Uri resource, and piping it appropriately.

Reviewed By: sriramramani

Differential Revision: D2919403
This commit is contained in:
Denis Koroskin 2016-02-09 17:01:37 -08:00 committed by Ahmed El-Helw
parent 88ebce0512
commit 0b6436b637
1 changed files with 6 additions and 3 deletions

View File

@ -28,7 +28,7 @@ import com.facebook.imagepipeline.request.ImageRequestBuilder;
}
final ImageRequestBuilder imageRequestBuilder;
if (isNetworkResource(source)) {
if (isUriResource(source)) {
imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(source));
} else {
Resources resources = context.getResources();
@ -42,7 +42,10 @@ import com.facebook.imagepipeline.request.ImageRequestBuilder;
return imageRequestBuilder.build();
}
private static boolean isNetworkResource(String source) {
return source.startsWith("http://") || source.startsWith("https://");
private static boolean isUriResource(String source) {
return
source.startsWith("http://") ||
source.startsWith("https://") ||
source.startsWith("data:");
}
}