Skip to content

Commit c39962b

Browse files
authored
Merge pull request joltup#193 from Saikedo/master
'boolean java.lang.String.isEmpty()' on a null object reference on certain Android phones.
2 parents 6120f48 + 0685344 commit c39962b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public void run() {
297297

298298
// find cached result if `key` property exists
299299
String cacheKey = this.taskId;
300-
String ext = this.options.appendExt.isEmpty() ? "" : "." + this.options.appendExt;
300+
String ext = (this.options.appendExt == null || this.options.appendExt.isEmpty()) ? "" : "." + this.options.appendExt;
301301

302302
if (this.options.key != null) {
303303
cacheKey = ReactNativeBlobUtilUtils.getMD5(this.options.key);
@@ -402,7 +402,7 @@ else if (value.equalsIgnoreCase("utf8"))
402402

403403
if (rawRequestBodyArray != null) {
404404
requestType = RequestType.Form;
405-
} else if (cType.isEmpty()) {
405+
} else if (cType == null || cType.isEmpty()) {
406406
if (!cType.equalsIgnoreCase("")) {
407407
builder.header("Content-Type", "application/octet-stream");
408408
}

android/src/main/java/com/ReactNativeBlobUtil/Utils/MimeType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class MimeType {
2727
public static String getFullFileName(String name, String mimeType) {
2828
// Prior to API 29, MimeType.BINARY_FILE has no file extension
2929
String ext = MimeType.getExtensionFromMimeType(mimeType);
30-
if (ext.isEmpty() || name.endsWith("." + "ext")) return name;
30+
if ((ext == null || ext.isEmpty()) || name.endsWith("." + "ext")) return name;
3131
else {
3232
String fn = name + "." + ext;
3333
if (fn.endsWith(".")) return StringUtils.stripEnd(fn, ".");

0 commit comments

Comments
 (0)