@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
44 lines • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractDappURLFromManifest = void 0;
function extractDappURLFromManifest(manifest) {
if (manifest && manifest.params && "dappUrl" in manifest.params) {
try {
const url = new URL(manifest.params.dappUrl);
return url;
}
catch (error) {
// Invalid URL
return undefined;
}
}
if (manifest &&
manifest.params &&
"dappURL" in manifest.params &&
typeof manifest.params.dappURL === "string") {
try {
const url = new URL(manifest.params.dappURL);
return url;
}
catch (error) {
// Invalid URL
return undefined;
}
}
if (manifest && manifest.dapp) {
try {
if (manifest.url instanceof URL) {
return manifest.url;
}
const url = new URL(manifest.url);
return url;
}
catch (error) {
// Invalid URL
return undefined;
}
}
return undefined;
}
exports.extractDappURLFromManifest = extractDappURLFromManifest;
//# sourceMappingURL=extractDappURLFromManifest.js.map