mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
fix link preview
This commit is contained in:
parent
c8149209a1
commit
cca38e270b
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user