diff --git a/src/plugins/core/java.rs b/src/plugins/core/java.rs index eed5cefbc..b16f33333 100644 --- a/src/plugins/core/java.rs +++ b/src/plugins/core/java.rs @@ -385,11 +385,17 @@ impl Backend for JavaPlugin { } fn fuzzy_match_filter(&self, versions: Vec, query: &str) -> eyre::Result> { - let escaped_query = regex::escape(query.trim_end_matches('-')); - let query = if query == "latest" { - "[0-9].*" - } else { - &escaped_query + let query_trim = regex::escape(query.trim_end_matches('-')); + let query_version = format!("{}[0-9.]+", regex::escape(query)); + let query_trim_version = format!("{}-[0-9.]+", query_trim); + let query = match query { + "latest" => "[0-9].*", + // ends with a dash; use + q if q.ends_with('-') => &query_version, + // not a shorthand version; use - + q if regex!("^[a-zA-Z]+$").is_match(q) => &query_trim_version, + // else; use trimmed query + _ => &query_trim, }; let query_regex = Regex::new(&format!("^{}([+-.].+)?$", query))?; let versions = versions diff --git a/src/toolset/mod.rs b/src/toolset/mod.rs index f471b5804..2b2e6a70d 100644 --- a/src/toolset/mod.rs +++ b/src/toolset/mod.rs @@ -355,7 +355,7 @@ impl Toolset { return None; } // prefix is something like "temurin-" or "corretto-" - let prefix = regex!(r"^[a-zA-Z]+-") + let prefix = regex!(r"^[a-zA-Z-]+-") .find(&tv.request.version()) .map(|m| m.as_str().to_string()); let latest_result = if bump {