Fixing crash when the last : is not present in an address

This commit is contained in:
Vitor Pamplona
2025-07-10 09:38:53 -04:00
parent 123803edd3
commit a2d16c173c

View File

@@ -66,8 +66,8 @@ data class Address(
fun parse(addressId: String): Address? =
try {
val parts = addressId.split(":", limit = 3)
if (parts.size > 1 && parts[1].length == 64 && Hex.isHex(parts[1])) {
Address(parts[0].toInt(), parts[1], parts[2])
if (parts.size > 2 && parts[1].length == 64 && Hex.isHex(parts[1])) {
Address(parts[0].toInt(), parts[1], parts.getOrNull(2) ?: "")
} else {
if (addressId.startsWith("naddr1")) {
val addr = Nip19Parser.uriToRoute(addressId)?.entity