Skip to content

Improve serialization of VFS URL query parameters #165

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

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
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
14 changes: 10 additions & 4 deletions src/utils/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@
/*
* Creates URL request path
*/
const encodeQueryData = data => Object.keys(data)
.filter(k => typeof data[k] !== 'object')
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(data[k]))
.join('&');
const encodeQueryData = (data, nesting = '') => {
const pairs = Object.entries(data).map(([key, val]) => {
if (typeof val === 'object') {
return encodeQueryData(val, nesting + `${key}.`);
} else {
return encodeURIComponent(nesting + key) + '=' + encodeURIComponent(val);
}
});
return pairs.join('&');
};

const bodyTypes = [
window.ArrayBuffer,
Expand Down