mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2024-05-18 00:52:40 +00:00
regex
This commit is contained in:
parent
294c77c01b
commit
26ac6e82dc
|
@ -121,7 +121,7 @@ where
|
|||
T: Clone,
|
||||
{
|
||||
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}`.
|
||||
// TODO: This should use a URL parser
|
||||
let captures = WEBFINGER_REGEX
|
||||
|
@ -288,6 +288,14 @@ mod tests {
|
|||
Ok("Владимир"),
|
||||
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!(
|
||||
Ok("تجريب"),
|
||||
extract_webfinger_name("acct:تجريب@example.com", &data)
|
||||
|
|
Loading…
Reference in a new issue