c98130cc08
* ui: Add the most basic workspace root in /ui * We already have a LICENSE file in the repository root * Change directory path in build scripts ui-v2 -> ui * Make yarn install flags configurable from elsewhere * Minimal workspace root makefile * Call the new docker specific target * Update yarn in the docker build image * Reconfigure the netlify target and move to the higher makefile * Move ui-v2 -> ui/packages/consul-ui * Change repo root to refleect new folder structure * Temporarily don't hoist consul-api-double * Fixup CI configuration * Fixup lint errors * Fixup Netlify target
28 lines
872 B
JavaScript
28 lines
872 B
JavaScript
export default function(encode) {
|
|
return function stringify(obj, parent) {
|
|
return Object.entries(obj)
|
|
.reduce(function(prev, [key, value], i) {
|
|
// if the value is undefined do nothing
|
|
if (typeof value === 'undefined') {
|
|
return prev;
|
|
}
|
|
let prop = encode(key);
|
|
// if we have a parent, prefix the property with that
|
|
if (typeof parent !== 'undefined') {
|
|
prop = `${parent}[${prop}]`;
|
|
}
|
|
// if the value is null just print the prop
|
|
if (value === null) {
|
|
return prev.concat(prop);
|
|
}
|
|
// anything nested, recur
|
|
if (typeof value === 'object') {
|
|
return prev.concat(stringify(value, prop));
|
|
}
|
|
// anything else print prop=value
|
|
return prev.concat(`${prop}=${encode(value)}`);
|
|
}, [])
|
|
.join('&');
|
|
};
|
|
}
|