mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-12 18:18:50 +00:00
get rid of the string arithmetics and just re-encode nip19 on the fly.
This commit is contained in:
@@ -16,13 +16,12 @@ object Parser {
|
||||
|
||||
def parseInput(input: String): Result =
|
||||
if input == "" then Left("")
|
||||
else {
|
||||
val spl = additions.split(input)
|
||||
val result = ByteVector
|
||||
.fromHex(spl.head)
|
||||
else
|
||||
ByteVector
|
||||
.fromHex(input)
|
||||
.flatMap(b => Try(Right(ByteVector32(b))).toOption)
|
||||
.getOrElse(
|
||||
NIP19.decode(spl.head) match {
|
||||
NIP19.decode(input) match {
|
||||
case Right(pp: ProfilePointer) => Right(pp)
|
||||
case Right(evp: EventPointer) => Right(evp)
|
||||
case Right(sk: PrivateKey) => Right(sk)
|
||||
@@ -43,17 +42,4 @@ object Parser {
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
val extraRelays = spl
|
||||
.drop(1)
|
||||
.toList
|
||||
.filter(e => e.startsWith("wss://") || e.startsWith("ws://"))
|
||||
|
||||
result.map {
|
||||
case a: AddressPointer => a.copy(relays = a.relays ::: extraRelays)
|
||||
case p: ProfilePointer => p.copy(relays = p.relays ::: extraRelays)
|
||||
case e: EventPointer => e.copy(relays = e.relays ::: extraRelays)
|
||||
case r => r
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user