OrdisPrime d091af4778
Basic purchasing + custom purchasing API (#20)
Endpoint for custom API: https://localhost:443/custom/addItem
example request:
{
"type": "Weapon",
"internalName": "/Lotus/Weapons/Grineer/Pistols/GrineerMicrowavegun/GrnMicrowavePistol",
"accountId": "6488fd2e7bec200069ca4242"
}
2023-06-14 02:26:19 +02:00

19 lines
701 B
TypeScript

const getJSONfromString = (str: string): any => {
const jsonSubstring = str.substring(0, str.lastIndexOf("}") + 1);
return JSON.parse(jsonSubstring);
};
export const getSubstringFromKeyword = (str: string, keyword: string): string => {
const index = str.indexOf(keyword);
if (index == -1) {
throw new Error(`keyword ${keyword} not found in string ${str}`);
}
return str.substring(index);
};
export const getSubstringFromKeywordToKeyword = (str: string, keywordBegin: string, keywordEnd: string): string => {
const beginIndex = str.lastIndexOf(keywordBegin) + 1;
const endIndex = str.indexOf(keywordEnd);
return str.substring(beginIndex, endIndex + 1);
};