Skip to content

Commit c736f16

Browse files
committedOct 18, 2019
Correctly detect VFS options on GET (fixes #18)
1 parent 3aa3575 commit c736f16

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed
 

‎src/vfs.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,22 @@ const createMiddleware = core => {
100100
});
101101
};
102102

103+
const createOptions = req => {
104+
const options = req.fields.options;
105+
if (typeof options === 'string') {
106+
try {
107+
return JSON.parse(req.fields.options) || {};
108+
} catch (e) {
109+
// Allow to fall through
110+
}
111+
}
112+
113+
return options || {};
114+
};
115+
103116
// Standard request with only a target
104117
const createRequestFactory = findMountpoint => (getter, method, readOnly, respond) => async (req, res) => {
105-
const options = req.fields.options || {};
118+
const options = createOptions(req);
106119
const args = [...getter(req, res), options];
107120

108121
const found = await findMountpoint(args[0]);
@@ -125,7 +138,7 @@ const createRequestFactory = findMountpoint => (getter, method, readOnly, respon
125138

126139
// Request that has a source and target
127140
const createCrossRequestFactory = findMountpoint => (getter, method, respond) => async (req, res) => {
128-
const [from, to, options] = [...getter(req, res), req.fields.options || {}];
141+
const [from, to, options] = [...getter(req, res), createOptions(req)];
129142

130143
const srcMount = await findMountpoint(from);
131144
const destMount = await findMountpoint(to);

0 commit comments

Comments
 (0)
Please sign in to comment.