You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fix for Issue #22 works only if the bytes are in the body of the request, not in query parameters. In this case, they're being removed by flattenRequestPayload even though the type generated is Uint8Array.
Changing the flattenRequestPayload function to below (see the added third if statement) seems to solve the problem. It reuses the replacer function behaviour.
function flattenRequestPayload<T extends RequestPayload>(
requestPayload: T,
path: string = ''
): FlattenedRequestPayload {
return Object.keys(requestPayload).reduce((acc: T, key: string): T => {
const value = requestPayload[key];
const newPath = path ? [path, key].join('.') : key;
const isNonEmptyPrimitiveArray =
Array.isArray(value) &&
value.every(v => isPrimitive(v)) &&
value.length > 0;
const isNonZeroValuePrimitive =
isPrimitive(value) && !isZeroValuePrimitive(value as Primitive);
let objectToMerge = {};
if (isPlainObject(value)) {
objectToMerge = flattenRequestPayload(value as RequestPayload, newPath);
} else if (isNonZeroValuePrimitive || isNonEmptyPrimitiveArray) {
objectToMerge = { [newPath]: value };
} else if (value && value.constructor === Uint8Array) {
objectToMerge = { [newPath]: b64Encode(value, 0, value.length) };
}
return { ...acc, ...objectToMerge };
}, {} as T) as FlattenedRequestPayload;
}
The text was updated successfully, but these errors were encountered:
The fix for Issue #22 works only if the bytes are in the body of the request, not in query parameters. In this case, they're being removed by
flattenRequestPayload
even though the type generated isUint8Array
.Changing the
flattenRequestPayload
function to below (see the added third if statement) seems to solve the problem. It reuses thereplacer
function behaviour.The text was updated successfully, but these errors were encountered: