forked from lavina/lavina
used regex_static in Jid (#1)
Reviewed-on: lavina/lavina#1 Co-authored-by: JustTestingV <JustTestingV@gmail.com> Co-committed-by: JustTestingV <JustTestingV@gmail.com>
This commit is contained in:
parent
6ed1f6be40
commit
e9fc74b46b
|
@ -759,6 +759,7 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http-body-util",
|
"http-body-util",
|
||||||
"hyper 1.0.0-rc.3",
|
"hyper 1.0.0-rc.3",
|
||||||
|
"lazy_static",
|
||||||
"nom",
|
"nom",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
|
|
|
@ -16,6 +16,7 @@ tracing-subscriber = "0.3.16"
|
||||||
futures-util = "0.3.25"
|
futures-util = "0.3.25"
|
||||||
prometheus = { version = "0.13.3", default-features = false }
|
prometheus = { version = "0.13.3", default-features = false }
|
||||||
regex = "1.7.1"
|
regex = "1.7.1"
|
||||||
|
lazy_static = "1.4.0"
|
||||||
nom = "7.1.3"
|
nom = "7.1.3"
|
||||||
tokio-rustls = "0.24.1"
|
tokio-rustls = "0.24.1"
|
||||||
rustls-pemfile = "1.0.2"
|
rustls-pemfile = "1.0.2"
|
||||||
|
|
|
@ -42,10 +42,12 @@ impl Display for Jid {
|
||||||
|
|
||||||
impl Jid {
|
impl Jid {
|
||||||
pub fn from_string(i: &str) -> Result<Jid> {
|
pub fn from_string(i: &str) -> Result<Jid> {
|
||||||
// TODO make regex static
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
let re = Regex::new(r"^(([a-zA-Z]+)@)?([a-zA-Z.]+)(/([a-zA-Z\-]+))?$").unwrap();
|
use lazy_static::lazy_static;
|
||||||
let m = re
|
lazy_static! {
|
||||||
|
static ref RE: Regex = Regex::new(r"^(([a-zA-Z]+)@)?([a-zA-Z.]+)(/([a-zA-Z\-]+))?$").unwrap();
|
||||||
|
}
|
||||||
|
let m = RE
|
||||||
.captures(i)
|
.captures(i)
|
||||||
.ok_or(ffail!("Incorrectly format jid: {i}"))?;
|
.ok_or(ffail!("Incorrectly format jid: {i}"))?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue