framework-do-dede 3.0.40 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28,7 +28,11 @@ export default class ControllerHandler {
|
|
|
28
28
|
const filterParams = this.filter(input.params, params);
|
|
29
29
|
const filterQueryParams = this.filter(input.query, query);
|
|
30
30
|
const filterHeaders = this.filter(input.headers, headers);
|
|
31
|
-
|
|
31
|
+
let body = input.body || {};
|
|
32
|
+
if (Object.keys(body).length > 0) {
|
|
33
|
+
body = this.normalizeBracketNotation(body);
|
|
34
|
+
}
|
|
35
|
+
mergedParams = { ...filterHeaders, ...filterParams, ...filterQueryParams, ...body };
|
|
32
36
|
request = { data: mergedParams, context: {} };
|
|
33
37
|
middlewaresExecuted = await this.executeMiddlewares(middlewares, request);
|
|
34
38
|
const response = await handler.instance[handler.methodName](request);
|
|
@@ -197,4 +201,24 @@ export default class ControllerHandler {
|
|
|
197
201
|
...debugError
|
|
198
202
|
};
|
|
199
203
|
}
|
|
204
|
+
normalizeBracketNotation(data) {
|
|
205
|
+
if (!data || typeof data !== "object")
|
|
206
|
+
return data;
|
|
207
|
+
const normalized = {};
|
|
208
|
+
for (const [rawKey, value] of Object.entries(data)) {
|
|
209
|
+
const key = String(rawKey);
|
|
210
|
+
const match = key.match(/^([^\[\]]+)\[([^\[\]]+)\]$/);
|
|
211
|
+
if (match) {
|
|
212
|
+
const parent = match[1];
|
|
213
|
+
const child = match[2];
|
|
214
|
+
if (!normalized[parent] || typeof normalized[parent] !== "object") {
|
|
215
|
+
normalized[parent] = {};
|
|
216
|
+
}
|
|
217
|
+
normalized[parent][child] = value;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
normalized[key] = value;
|
|
221
|
+
}
|
|
222
|
+
return normalized;
|
|
223
|
+
}
|
|
200
224
|
}
|