Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Fix search query parameter validation #863

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub async fn search_for_project(

let offset: usize = info.offset.as_deref().unwrap_or("0").parse()?;
let index = info.index.as_deref().unwrap_or("relevance");
let limit = info.limit.as_deref().unwrap_or("10").parse()?;
let limit = info.limit.as_deref().unwrap_or("10").parse::<usize>()?.min(100);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be max instead of min?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, min returns the minimum of the two. If the inputs are 10 and 100, it returns 10. If the inputs are 400 and 100, it returns 100.


let sort = get_sort_index(config, index)?;
let meilisearch_index = client.get_index(sort.0).await?;
Expand Down
Loading