diff --git a/core/src/web/filesystem.ts b/core/src/web/filesystem.ts index 3e9985832..ce27dca3c 100644 --- a/core/src/web/filesystem.ts +++ b/core/src/web/filesystem.ts @@ -202,11 +202,12 @@ export class FilesystemPluginWeb extends WebPlugin implements FilesystemPlugin { let parentEntry = await this.dbRequest('get', [parentPath]) as EntryObj; if (parentEntry === undefined) { - const parentArgPathIndex = parentPath.indexOf('/', 1); - const parentArgPath = parentArgPathIndex !== -1 ? parentPath.substr(parentArgPathIndex) : '/'; - await this.mkdir({path: parentArgPath, directory: options.directory, recursive: true}); + const subDirIndex = parentPath.indexOf('/', 1); + if (subDirIndex !== -1) { + const parentArgPath = parentPath.substr(subDirIndex); + await this.mkdir({path: parentArgPath, directory: options.directory, recursive: true}); + } } - if (occupiedEntry !== undefined) { data = occupiedEntry.content + data; ctime = occupiedEntry.ctime;