Skip to content

Commit

Permalink
Added support for WPWebViewClient to pass the token for image reque…
Browse files Browse the repository at this point in the history
…sts.

Moved `isImageUrl` method to `UrlUtils` since it is being used in two places now.

Fixes #2444
  • Loading branch information
roundhill committed Mar 20, 2015
1 parent 7d96a03 commit 2879710
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.wordpress.android.util;

import android.net.Uri;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;

Expand Down Expand Up @@ -195,4 +196,14 @@ public static boolean isValidUrlAndHostNotNull(String url) {
}
return true;
}

// returns true if the passed url is for an image
public static boolean isImageUrl(String url) {
if (TextUtils.isEmpty(url)) return false;

String cleanedUrl = removeQuery(url.toLowerCase());

return cleanedUrl.endsWith("jpg") || cleanedUrl.endsWith("jpeg") ||
cleanedUrl.endsWith("gif") || cleanedUrl.endsWith("png");
}
}

0 comments on commit 2879710

Please sign in to comment.