idle_moloch/lib/v3-periphery/test/shared/extractJSONFromURI.ts
2024-11-01 11:55:27 +01:00

6 lines
286 B
TypeScript

export function extractJSONFromURI(uri: string): { name: string; description: string; image: string } {
const encodedJSON = uri.substr('data:application/json;base64,'.length)
const decodedJSON = Buffer.from(encodedJSON, 'base64').toString('utf8')
return JSON.parse(decodedJSON)
}