.await
}
Err(_) => {
- let (kind, identifier) = query.split_at(1);
+ let mut chars = query.chars();
+ let kind = chars.next();
+ let identifier = chars.as_str();
match kind {
- "@" => {
+ Some('@') => {
let id =
webfinger_resolve_actor::<ApubPerson>(identifier, context, request_counter).await?;
Ok(SearchableObjects::Person(
.await?,
))
}
- "!" => {
+ Some('!') => {
let id =
webfinger_resolve_actor::<ApubCommunity>(identifier, context, request_counter).await?;
Ok(SearchableObjects::Community(
let (_, domain) = identifier
.splitn(2, '@')
.collect_tuple()
- .expect("invalid query");
+ .ok_or_else(|| LemmyError::from_message("Invalid webfinger query, missing domain"))?;
let fetch_url = format!(
"{}://{}/.well-known/webfinger?resource=acct:{}",
protocol, domain, identifier