New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dont require leading ! or @ for webfinger resolve #4513
Conversation
@@ -18,28 +19,22 @@ use url::Url; | |||
/// which gets resolved to an URL. | |||
#[tracing::instrument(skip_all)] | |||
pub(crate) async fn search_query_to_object_id( | |||
query: &str, | |||
mut query: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having this a a mutable param, I think it'd be better to just create a new var inside this function. immutable functions and all that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately String::remove only works on a mutable string, and I dont see a better alternative in this case. Sure I could declare a separate mut inside the function, but that wouldnt really change anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still an immutable function. mut
before a parameter name does the same thing as putting let mut foo = foo;
in the function body.
), | ||
_ => return Err(LemmyErrorType::InvalidQuery)?, | ||
if query.starts_with('!') || query.starts_with('@') { | ||
query.remove(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just build the new var here. let query_2 = if .... else
I noticed that this requirement is totally unnecessary as we can determine the type from the response. Only limitation is if there is a community and user with the same name, then it may be necessary to fetch by url.