1
2
3
4
5
6
7
8
export function githubPayloadStringToNormalizedJSON(payload: string) {
const payloadObject = JSON.parse(payload);
// GitHub sends its JSON with an indentation of 2 spaces and a line break at the end
const payloadString = JSON.stringify(payload, null, 2) + "\n";
return payloadString.replace(/[^\\]\\u[\da-f]{4}/g, (s) => {
return s.substr(0, 3) + s.substr(3).toUpperCase();
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
1
karfau avatar

It looks like this is no longer needed, I was able to just do JSON.parse(req.body.payload)and it worked just fine

October 23, 2023