mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-25 12:57:21 +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();
|
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.");
|
Log.i(TAG, "Image URL was invalid mime type. Skipping.");
|
||||||
imageUrl = Optional.absent();
|
imageUrl = Optional.absent();
|
||||||
}
|
}
|
||||||
|
@ -98,11 +98,15 @@ public final class LinkPreviewUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVaildMimeType(@NonNull String url) {
|
public static boolean isValidMimeType(@NonNull String url) {
|
||||||
String[] vaildMimeType = {"jpg", "png", "gif", "jpeg"};
|
String[] validMimeType = {".jpg", ".png", ".gif", ".jpeg"};
|
||||||
if (url.contains(".")) {
|
if (url.contains(".")) {
|
||||||
String extenstion = url.substring(url.lastIndexOf(".") + 1).toLowerCase();
|
for (String mimeType : validMimeType) {
|
||||||
return Arrays.asList(vaildMimeType).contains(extenstion);
|
if (url.contains(mimeType)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user