Skip to content

Commit

Permalink
Add lightning regex
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Feb 5, 2024
1 parent 70cdfeb commit 2c3a7c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ serde_json = "1.0"
tokio = { version = "1.12.0", features = ["full"] }
tower-http = { version = "0.4.0", features = ["cors"] }
urlencoding = "2.1.2"
regex = "1.10.2"
lazy_static = "1.4"

[dev-dependencies]
dotenv = "0.15.0"
15 changes: 14 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
use bitcoin::bip32::ExtendedPrivKey;
use bitcoin::hashes::{sha256, Hash};
use lazy_static::lazy_static;
use nostr::key::XOnlyPublicKey;
use regex::Regex;

lazy_static! {
static ref LN_REG: Regex =
Regex::new(r"^\u{26A1}[\u{FE00}-\u{FE0F}]?$").expect("Invalid regex");
}

pub fn map_emoji(emoji: &str) -> Option<&str> {
match emoji {
"❤" | "+" | "" => Some("❤️"),
"⚡️" => Some("⚡"),
_ => None,
str => {
if LN_REG.is_match(str) {
Some("⚡")
} else {
None
}
}
}
}

Expand Down

0 comments on commit 2c3a7c2

Please sign in to comment.