Handle case-insensitive payload keys
This commit is contained in:
parent
84583abb8c
commit
e9b171b8df
12
server.js
12
server.js
@ -61,11 +61,15 @@ function parseMessage(buffer) {
|
||||
const body = buffer.toString("utf8");
|
||||
try {
|
||||
const parsed = JSON.parse(body);
|
||||
const normalized = Object.keys(parsed || {}).reduce((acc, key) => {
|
||||
acc[key.toLowerCase()] = parsed[key];
|
||||
return acc;
|
||||
}, {});
|
||||
return {
|
||||
action: parsed.action || "create",
|
||||
id: parsed.id,
|
||||
text: parsed.text,
|
||||
requestId: parsed.request_id,
|
||||
action: normalized.action || "create",
|
||||
id: normalized.id,
|
||||
text: normalized.text,
|
||||
requestId: normalized.request_id || normalized.requestid,
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user