Skip to content

Commit 4d61abb

Browse files
committed
Added support for WPWebViewClient to pass the token for image requests.
Moved `isImageUrl` method to `UrlUtils` since it is being used in two places now. Fixes #2444
1 parent 1e5ffa6 commit 4d61abb

File tree

1 file changed

+11
-0
lines changed
  • WordPressUtils/src/main/java/org/wordpress/android/util

1 file changed

+11
-0
lines changed

WordPressUtils/src/main/java/org/wordpress/android/util/UrlUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.wordpress.android.util;
22

33
import android.net.Uri;
4+
import android.text.TextUtils;
45
import android.webkit.MimeTypeMap;
56
import android.webkit.URLUtil;
67

@@ -195,4 +196,14 @@ public static boolean isValidUrlAndHostNotNull(String url) {
195196
}
196197
return true;
197198
}
199+
200+
// returns true if the passed url is for an image
201+
public static boolean isImageUrl(String url) {
202+
if (TextUtils.isEmpty(url)) return false;
203+
204+
String cleanedUrl = removeQuery(url.toLowerCase());
205+
206+
return cleanedUrl.endsWith("jpg") || cleanedUrl.endsWith("jpeg") ||
207+
cleanedUrl.endsWith("gif") || cleanedUrl.endsWith("png");
208+
}
198209
}

0 commit comments

Comments
 (0)