do not act on input blank.

This commit is contained in:
fiatjaf 2023-03-25 14:42:28 -03:00
parent c2a826e854
commit b94219512f
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
2 changed files with 3 additions and 2 deletions

View File

@ -85,7 +85,7 @@ object Main extends IOWebApp {
cls := "w-full max-h-96 p-3 rounded", cls := "w-full max-h-96 p-3 rounded",
styleAttr := "min-height: 280px; font-family: monospace", styleAttr := "min-height: 280px; font-family: monospace",
spellCheck := false, spellCheck := false,
placeholder := "paste something nostric", placeholder := "paste something nostric (event JSON, nprofile, npub, nevent etc or hex key or id)",
onInput --> (_.foreach(_ => onInput --> (_.foreach(_ =>
self.value.get.flatMap(store.input.set) self.value.get.flatMap(store.input.set)
)), )),

View File

@ -12,7 +12,8 @@ type Result = Either[
] ]
object Parser { object Parser {
def parseInput(input: String): Result = def parseInput(input: String): Result = if input == "" then Left("")
else
ByteVector ByteVector
.fromHex(input) .fromHex(input)
.flatMap(b => Try(Right(ByteVector32(b))).toOption) .flatMap(b => Try(Right(ByteVector32(b))).toOption)