mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2024-06-09 00:39:29 +00:00
regex
This commit is contained in:
parent
294c77c01b
commit
26ac6e82dc
|
@ -121,7 +121,7 @@ where
|
||||||
T: Clone,
|
T: Clone,
|
||||||
{
|
{
|
||||||
static WEBFINGER_REGEX: Lazy<Regex> =
|
static WEBFINGER_REGEX: Lazy<Regex> =
|
||||||
Lazy::new(|| Regex::new(r"^acct:([\p{L}0-9_]+)@(.*)$").expect("compile regex"));
|
Lazy::new(|| Regex::new(r"^acct:([\p{L}0-9_\.\-]+)@(.*)$").expect("compile regex"));
|
||||||
// Regex to extract usernames from webfinger query. Supports different alphabets using `\p{L}`.
|
// Regex to extract usernames from webfinger query. Supports different alphabets using `\p{L}`.
|
||||||
// TODO: This should use a URL parser
|
// TODO: This should use a URL parser
|
||||||
let captures = WEBFINGER_REGEX
|
let captures = WEBFINGER_REGEX
|
||||||
|
@ -288,6 +288,14 @@ mod tests {
|
||||||
Ok("Владимир"),
|
Ok("Владимир"),
|
||||||
extract_webfinger_name("acct:Владимир@example.com", &data)
|
extract_webfinger_name("acct:Владимир@example.com", &data)
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
Ok("example.com"),
|
||||||
|
extract_webfinger_name("acct:example.com@example.com", &data)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
Ok("da-sh"),
|
||||||
|
extract_webfinger_name("acct:da-sh@example.com", &data)
|
||||||
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Ok("تجريب"),
|
Ok("تجريب"),
|
||||||
extract_webfinger_name("acct:تجريب@example.com", &data)
|
extract_webfinger_name("acct:تجريب@example.com", &data)
|
||||||
|
|
Loading…
Reference in a new issue