diff --git a/__tests__/vfs.js b/__tests__/vfs.js index ca0a76b..4310615 100644 --- a/__tests__/vfs.js +++ b/__tests__/vfs.js @@ -79,7 +79,7 @@ describe('VFS', () => { .toBeInstanceOf(ArrayBuffer); }); - test('writefile - blob', () => { + test('#writefile - blob', () => { return expect(call('writefile', 'null:/filename', new Blob())) .resolves .toBe(-1); diff --git a/src/adapters/vfs/system.js b/src/adapters/vfs/system.js index ceee251..3c653f4 100644 --- a/src/adapters/vfs/system.js +++ b/src/adapters/vfs/system.js @@ -59,7 +59,7 @@ const methods = (core, request) => { return { readdir: ({path}, options) => request('readdir', { path, - options: {} + options, }, 'json').then(({body}) => body), readfile: ({path}, type, options) => @@ -89,7 +89,7 @@ const methods = (core, request) => { stat: passthrough('stat'), url: ({path}, options) => Promise.resolve( - core.url(`/vfs/readfile?path=${encodeURIComponent(path)}`) + core.url(`/vfs/readfile?path.s=${encodeURIComponent(path)}`) ), search: ({path}, pattern, options) => @@ -102,7 +102,7 @@ const methods = (core, request) => { download: ({path}, options = {}) => { const json = encodeURIComponent(JSON.stringify({download: true})); - return Promise.resolve(`/vfs/readfile?options=${json}&path=` + encodeURIComponent(path)) + return Promise.resolve(`/vfs/readfile?options=${json}&path.s=` + encodeURIComponent(path)) .then(url => { return (options.target || window).open(url); }); diff --git a/src/vfs.js b/src/vfs.js index 505ff14..5dc80e2 100644 --- a/src/vfs.js +++ b/src/vfs.js @@ -74,6 +74,13 @@ const handleDirectoryList = (path, options) => result => filter: options.filter })); +// Returns a new "options" object without properties from "ignore" +const filterOptions = (ignore, options) => Object.fromEntries( + Object + .entries(options) + .filter(([k]) => !ignore.includes(k)) +); + /** * Read a directory * @@ -82,7 +89,7 @@ const handleDirectoryList = (path, options) => result => * @return {Promise} A list of files */ export const readdir = (adapter, mount) => (path, options = {}) => - adapter.readdir(pathToObject(path), options, mount) + adapter.readdir(pathToObject(path), filterOptions(['showHiddenFiles', 'filter'], options), mount) .then(handleDirectoryList(path, options)); /**