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