Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
fix namedesc parsing to support basically any character in the name.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Dec 8, 2022
1 parent ff6a08c commit 52c7212
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions app/src/main/scala/HubActivity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,22 @@ object HubActivity {
def itemsLength: Int =
txInfos.size + paymentInfos.size + lnUrlPayLinks.size + relayedPreimageInfos.size

def getNameFromNameDesc(text: String): Option[String] =
"""^\w+: """.r.findFirstIn(text).map(prefix => prefix.split(": ")(0))
def getNameFromNameDesc(text: String): Option[String] = {
val spl = text.split(": ")
spl.size match {
case 1 => None
case _ if spl.head.size < 30 => Some(spl.head)
case _ => None
}
}

def expellNameFromNameDesc(text: String): String =
"""^\w+: """.r.split(text).last
def expellNameFromNameDesc(text: String): String = {
val spl = text.split(": ")
spl.size match {
case 1 => text
case _ => spl.drop(1).mkString(": ")
}
}
}

class HubActivity
Expand Down

0 comments on commit 52c7212

Please sign in to comment.