Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion __tests__/vfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/adapters/vfs/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand All @@ -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);
});
Expand Down
9 changes: 8 additions & 1 deletion src/vfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -82,7 +89,7 @@ const handleDirectoryList = (path, options) => result =>
* @return {Promise<object[]>} 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));

/**
Expand Down