Skip to content
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

Merged
merged 3 commits into from Mar 15, 2024

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Mar 6, 2024

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.

@@ -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,
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Collaborator

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);
Copy link
Member

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

@dessalines dessalines merged commit 9d4299a into main Mar 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants