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");
|
const body = buffer.toString("utf8");
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(body);
|
const parsed = JSON.parse(body);
|
||||||
|
const normalized = Object.keys(parsed || {}).reduce((acc, key) => {
|
||||||
|
acc[key.toLowerCase()] = parsed[key];
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
return {
|
return {
|
||||||
action: parsed.action || "create",
|
action: normalized.action || "create",
|
||||||
id: parsed.id,
|
id: normalized.id,
|
||||||
text: parsed.text,
|
text: normalized.text,
|
||||||
requestId: parsed.request_id,
|
requestId: normalized.request_id || normalized.requestid,
|
||||||
};
|
};
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user