Skip to content

Commit e30ee8f

Browse files
committed
Fix IndexOutOfBounds when downloadFile doesnt have a /
1 parent 2b90c0b commit e30ee8f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

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

0 commit comments

Comments
 (0)