Skip to content

Tweak handling of pre-release versions and wildcard ranges #188

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

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 10 additions & 5 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,19 @@ fn match_version(conn: &Connection, name: &str, version: Option<&str>) -> Option
versions_sem
};

// semver is acting weird for '*' (any) range if a crate only have pre-release versions
// return first version if requested version is '*'
if req_version == "*" && !versions_sem.is_empty() {
return Some(format!("{}", versions_sem[0]));
for version in &versions_sem {
if req_sem_ver.matches(&version) {
return Some(format!("{}", version));
}
}

// For crates that have only pre-release versions, ranges like '"*"' will not match any
// versions. Try matching without the pre-release tag.
for version in &versions_sem {
if req_sem_ver.matches(&version) {
let mut version_without_pre = version.clone();
version_without_pre.pre.clear();

if req_sem_ver.matches(&version_without_pre) {
return Some(format!("{}", version));
}
}
Expand Down