fix: dont fail to render with invalid URLs

This commit is contained in:
Alejandro Gomez
2023-01-14 12:57:36 +01:00
parent 06702a5174
commit 731aa68b44
4 changed files with 71 additions and 70 deletions

View File

@ -62,8 +62,13 @@ export function hexToBech32(hrp, hex) {
return "";
}
let buf = secp.utils.hexToBytes(hex);
return bech32.encode(hrp, bech32.toWords(buf));
try {
let buf = secp.utils.hexToBytes(hex);
return bech32.encode(hrp, bech32.toWords(buf));
} catch (e) {
console.warn("Invalid hex", hex, e);
return "";
}
}
/**
@ -122,4 +127,4 @@ export function extractLnAddress(lnurl) {
}
}
return lnurl;
}
}