infrastructure-upgrade/lib/v3-periphery/test/shared/extractJSONFromURI.ts

6 lines
286 B
TypeScript
Raw Normal View History

2023-04-08 21:46:18 +03:00
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)
}