Remove 1 indentation level from uriToRoute()

This commit is contained in:
Chemaclass
2023-03-03 23:26:35 +01:00
parent b35a59372c
commit fd58da2a93
@@ -14,13 +14,13 @@ class Nip19 {
enum class Type { enum class Type {
USER, NOTE, RELAY, ADDRESS USER, NOTE, RELAY, ADDRESS
} }
data class Return(val type: Type, val hex: String) data class Return(val type: Type, val hex: String)
fun uriToRoute(uri: String?): Return? { fun uriToRoute(uri: String?): Return? {
try { try {
val key = uri?.removePrefix("nostr:") val key = uri?.removePrefix("nostr:") ?: return null
if (key != null) {
val bytes = key.bechToBytes() val bytes = key.bechToBytes()
if (key.startsWith("npub")) { if (key.startsWith("npub")) {
return Return(Type.USER, bytes.toHexKey()) return Return(Type.USER, bytes.toHexKey())
@@ -55,7 +55,6 @@ class Nip19 {
if (d != null) if (d != null)
return Return(Type.ADDRESS, "$kind:$author:$d") return Return(Type.ADDRESS, "$kind:$author:$d")
} }
}
} catch (e: Throwable) { } catch (e: Throwable) {
println("Issue trying to Decode NIP19 ${uri}: ${e.message}") println("Issue trying to Decode NIP19 ${uri}: ${e.message}")
//e.printStackTrace() //e.printStackTrace()
@@ -84,7 +83,7 @@ fun parseTLV(data: ByteArray): Map<Byte, List<ByteArray>> {
val t = rest[0] val t = rest[0]
val l = rest[1] val l = rest[1]
val v = rest.sliceArray(IntRange(2, (2 + l) - 1)) val v = rest.sliceArray(IntRange(2, (2 + l) - 1))
rest = rest.sliceArray(IntRange(2 + l, rest.size-1)) rest = rest.sliceArray(IntRange(2 + l, rest.size - 1))
if (v.size < l) continue if (v.size < l) continue
if (!result.containsKey(t)) { if (!result.containsKey(t)) {