2
0

🐛 Fix webhook default timeout and unoptimized json parser (#1492)

This commit is contained in:
Baptiste Arnaud
2024-05-02 16:50:06 +02:00
committed by GitHub
parent b4ae098440
commit 7d70f0243b
2 changed files with 20 additions and 10 deletions

View File

@ -12,8 +12,7 @@
- After the match there is , OR } without " after it OR ] without " after it
*/
export const JSONParse = (json: string) => {
const numbersBiggerThanMaxInt =
/(?<=[^\\]":[\[]?|[^\\]":\[.*)(-?\d{17,}|-?(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))(?=,|\}[^"]|\][^"])/g
const numbersBiggerThanMaxInt = /(?<!\\)":\s*(-?\d{17,})(?=[,\]}])/g
const serializedData = json.replace(numbersBiggerThanMaxInt, `"$1n"`)
return JSON.parse(serializedData, (_, value) => {