MCPcopy Create free account
hub / github.com/pollinations/pollinations / formDataToObject

Function formDataToObject

shared/observability/request-inputs.ts:123–147  ·  view source on GitHub ↗
(formData: FormData)

Source from the content-addressed store, hash-verified

121}
122
123function formDataToObject(formData: FormData): Record<string, unknown> {
124 const result: Record<string, unknown> = {};
125
126 for (const [key, value] of formData.entries()) {
127 const serialized =
128 value instanceof File
129 ? {
130 name: value.name,
131 size: value.size,
132 type: value.type,
133 }
134 : value;
135
136 const existing = result[key];
137 if (existing === undefined) {
138 result[key] = serialized;
139 } else if (Array.isArray(existing)) {
140 existing.push(serialized);
141 } else {
142 result[key] = [existing, serialized];
143 }
144 }
145
146 return result;
147}
148
149function removeEmptyRecord<T extends Record<string, unknown>>(
150 record: T,

Callers 1

requestBodyFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected