Allow to search for usernames containing "-" character
This commit is contained in:
parent
03c442ad88
commit
fd067713d7
3 changed files with 7 additions and 4 deletions
|
@ -32,7 +32,8 @@ enum SearchQuery {
|
|||
fn parse_profile_query(query: &str) ->
|
||||
Result<(String, Option<String>), ValidationError>
|
||||
{
|
||||
let acct_regexp = Regex::new(r"^@?(?P<user>\w+)(@(?P<instance>[\w\.-]+))?$").unwrap();
|
||||
// See also: USERNAME_RE in models::profiles::validators
|
||||
let acct_regexp = Regex::new(r"^@?(?P<user>[\w\.-]+)(@(?P<instance>[\w\.-]+))?$").unwrap();
|
||||
let acct_caps = acct_regexp.captures(query)
|
||||
.ok_or(ValidationError("invalid search query"))?;
|
||||
let username = acct_caps.name("user")
|
||||
|
|
|
@ -8,8 +8,9 @@ use crate::errors::{DatabaseError, ValidationError};
|
|||
use crate::models::profiles::queries::get_profiles_by_accts;
|
||||
use crate::models::profiles::types::DbActorProfile;
|
||||
|
||||
const MENTION_RE: &str = r"@?(?P<user>\w+)@(?P<instance>.+)";
|
||||
const MENTION_SEARCH_RE: &str = r"(?m)(?P<before>^|\s)@(?P<user>\w+)@(?P<instance>\S+)";
|
||||
// See also: USERNAME_RE in models::profiles::validators
|
||||
const MENTION_RE: &str = r"@?(?P<user>[\w\.-]+)@(?P<instance>.+)";
|
||||
const MENTION_SEARCH_RE: &str = r"(?m)(?P<before>^|\s)@(?P<user>[\w\.-]+)@(?P<instance>\S+)";
|
||||
const MENTION_SEARCH_SECONDARY_RE: &str = r"^(?P<instance>[\w\.-]+\w)(?P<after>(\.|<br>|\.<br>)?)$";
|
||||
|
||||
/// Finds everything that looks like a mention
|
||||
|
|
|
@ -22,7 +22,8 @@ async fn get_user_info(
|
|||
) -> Result<JsonResourceDescriptor, HttpError> {
|
||||
// Parse 'acct' URI
|
||||
// https://datatracker.ietf.org/doc/html/rfc7565#section-7
|
||||
let uri_regexp = Regex::new(r"acct:(?P<user>[\w\.]+)@(?P<instance>.+)").unwrap();
|
||||
// See also: USERNAME_RE in models::profiles::validators
|
||||
let uri_regexp = Regex::new(r"acct:(?P<user>[\w\.-]+)@(?P<instance>.+)").unwrap();
|
||||
let uri_caps = uri_regexp.captures(&query_params.resource)
|
||||
.ok_or(ValidationError("invalid query target"))?;
|
||||
let username = uri_caps.name("user")
|
||||
|
|
Loading…
Reference in a new issue