Skip to content

Commit 9ae3316

Browse files
committed
Fix IndexOutOfBounds when downloadFile doesnt have a /
1 parent f034c1f commit 9ae3316

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

android/src/main/java/io/fullstack/firestack/FirestackStorage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ public void downloadFile(final String urlStr,
113113
@Override
114114
public void doInBackground(StreamDownloadTask.TaskSnapshot taskSnapshot, InputStream inputStream) throws IOException {
115115
int indexOfLastSlash = localFile.lastIndexOf("/");
116-
String pathMinusFileName = localFile.substring(0, indexOfLastSlash) + "/";
117-
String filename = localFile.substring(indexOfLastSlash+1);
116+
String pathMinusFileName = indexOfLastSlash>0 ? localFile.substring(0, indexOfLastSlash) + "/" : "/";
117+
String filename = indexOfLastSlash>0 ? localFile.substring(indexOfLastSlash+1) : localFile;
118118
File fileWithJustPath = new File(pathMinusFileName);
119119
if (!fileWithJustPath.mkdirs()) {
120120
Log.e(TAG, "Directory not created");

0 commit comments

Comments
 (0)