Skip to content
Prev Previous commit
Next Next commit
[autofix.ci] apply automated fixes
  • Loading branch information
autofix-ci[bot] authored Nov 25, 2025
commit ee83cd04286b90caa2099d16a2308f8e94c805a7
7 changes: 3 additions & 4 deletions src/backend/jq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn extract_recursive(json: &serde_json::Value, path: &str, results: &mut Vec<Str

// Handle field access with possible continuation
// Find where the field name ends (at '.' or '[')
let (field, rest) = if let Some(idx) = path.find(|c| c == '.' || c == '[') {
let (field, rest) = if let Some(idx) = path.find(['.', '[']) {
let (f, r) = path.split_at(idx);
// Strip the leading dot if present, but preserve '[' for array handling
let rest = if r.starts_with('.') { &r[1..] } else { r };
Expand All @@ -131,11 +131,10 @@ fn extract_recursive(json: &serde_json::Value, path: &str, results: &mut Vec<Str
(path, "")
};

if let Some(obj) = json.as_object() {
if let Some(val) = obj.get(field) {
if let Some(obj) = json.as_object()
&& let Some(val) = obj.get(field) {
extract_recursive(val, rest, results);
}
}
}

fn extract_values(json: &serde_json::Value, results: &mut Vec<String>) {
Expand Down
5 changes: 2 additions & 3 deletions src/backend/version_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ pub fn parse_version_list(
// If a JSON path is provided (like ".[].version" or ".versions"), try to use it
// but fall back to text parsing if JSON parsing fails
if let Some(json_path) = version_json_path {
if let Ok(json) = serde_json::from_str::<serde_json::Value>(trimmed) {
if let Ok(extracted) = jq::extract(&json, json_path) {
if let Ok(json) = serde_json::from_str::<serde_json::Value>(trimmed)
&& let Ok(extracted) = jq::extract(&json, json_path) {
versions = extracted;
}
}
// If JSON parsing failed or path extraction failed, fall through to text parsing below
}
// If a regex is provided, use it to extract versions
Expand Down
Loading