Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): remove data url header on writeFile if no encoding is passed #1909

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/src/web/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ export class FilesystemPluginWeb extends WebPlugin implements FilesystemPlugin {
if (occupiedEntry && occupiedEntry.type === 'directory')
throw('The supplied path is a directory.');

// const encoding = options.encoding;
const encoding = options.encoding;
const parentPath = path.substr(0, path.lastIndexOf('/'));

let parentEntry = await this.dbRequest('get', [parentPath]) as EntryObj;
if (parentEntry === undefined) {
const subDirIndex = parentPath.indexOf('/', 1);
if (subDirIndex !== -1) {
const parentArgPath = parentPath.substr(subDirIndex);
await this.mkdir({path: parentArgPath, directory: options.directory, createIntermediateDirectories: true})
await this.mkdir({path: parentArgPath, directory: options.directory, createIntermediateDirectories: true});
}
}
const now = Date.now();
Expand All @@ -173,7 +173,7 @@ export class FilesystemPluginWeb extends WebPlugin implements FilesystemPlugin {
size: data.length,
ctime: now,
mtime: now,
content: data
content: !encoding && data.indexOf(',') >= 0 ? data.split(',')[1] : data,
};
await this.dbRequest('put', [pathObj]);
return {};
Expand All @@ -200,7 +200,7 @@ 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));
await this.mkdir({path: parentArgPath, directory: options.directory, createIntermediateDirectories: true})
await this.mkdir({path: parentArgPath, directory: options.directory, createIntermediateDirectories: true});
}

if (occupiedEntry !== undefined) {
Expand Down