diff --git a/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java b/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java index 219d5c8d41..3e4355da82 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java +++ b/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java @@ -145,7 +145,7 @@ public class LinkPreviewRepository implements InjectableType { imageUrl = Optional.absent(); } - if (imageUrl.isPresent() && !LinkPreviewUtil.isVaildMimeType(imageUrl.get())) { + if (imageUrl.isPresent() && !LinkPreviewUtil.isValidMimeType(imageUrl.get())) { Log.i(TAG, "Image URL was invalid mime type. Skipping."); imageUrl = Optional.absent(); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewUtil.java b/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewUtil.java index 39aacf9a91..0a05c95b56 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewUtil.java +++ b/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewUtil.java @@ -98,11 +98,15 @@ public final class LinkPreviewUtil { } } - public static boolean isVaildMimeType(@NonNull String url) { - String[] vaildMimeType = {"jpg", "png", "gif", "jpeg"}; + public static boolean isValidMimeType(@NonNull String url) { + String[] validMimeType = {".jpg", ".png", ".gif", ".jpeg"}; if (url.contains(".")) { - String extenstion = url.substring(url.lastIndexOf(".") + 1).toLowerCase(); - return Arrays.asList(vaildMimeType).contains(extenstion); + for (String mimeType : validMimeType) { + if (url.contains(mimeType)) { + return true; + } + } + return false; } return true; }