Added check for null in SyndTypeUtils

This commit is contained in:
daniel oeh 2012-10-16 11:41:47 +02:00
parent 164ca08123
commit 3f8f9be652
1 changed files with 13 additions and 7 deletions

View File

@ -15,7 +15,11 @@ public class SyndTypeUtils {
}
public static boolean typeValid(String type) {
return type.matches(VALID_MIMETYPE);
if (type == null) {
return false;
} else {
return type.matches(VALID_MIMETYPE);
}
}
/**
@ -24,12 +28,14 @@ public class SyndTypeUtils {
* the type is not supported, this method will return null.
*/
public static String getValidMimeTypeFromUrl(String url) {
String extension = FilenameUtils.getExtension(url);
if (extension != null) {
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
extension);
if (type != null && typeValid(type)) {
return type;
if (url != null) {
String extension = FilenameUtils.getExtension(url);
if (extension != null) {
String type = MimeTypeMap.getSingleton()
.getMimeTypeFromExtension(extension);
if (type != null && typeValid(type)) {
return type;
}
}
}
return null;