UNPKG

poem-together-distance3

Version:
23 lines (22 loc) 547 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getWeb3AssetUrl = getWeb3AssetUrl; exports.requestWeb3Asset = requestWeb3Asset; function getWeb3AssetUrl(url) { if (!url) { return url; } let requestURL = url; if (url.startsWith('ipfs://')) { requestURL = `https://ipfs.io/ipfs/${url.replace('ipfs://', '')}`; } return requestURL; } async function requestWeb3Asset(url) { if (!url) { throw new Error('URL not set'); } return fetch(getWeb3AssetUrl(url)).then(res => res.json()); }