diff --git a/crates/jsonschema-referencing/src/registry.rs b/crates/jsonschema-referencing/src/registry.rs index 0b420caf..7d8171e0 100644 --- a/crates/jsonschema-referencing/src/registry.rs +++ b/crates/jsonschema-referencing/src/registry.rs @@ -461,14 +461,8 @@ fn collect_external_resources( { continue; } - // Handle local references separately as they may have nested references to external resources - if reference.starts_with('#') { - if reference == "#" { - continue; - } - if let Some(referenced) = pointer(contents, reference.trim_start_matches('#')) { - collect_external_resources(base, referenced, collected, seen)?; - } + + if reference == "#" { continue; } @@ -480,6 +474,14 @@ fn collect_external_resources( return Ok(()); } + // Handle local references separately as they may have nested references to external resources + if reference.starts_with('#') { + if let Some(referenced) = pointer(contents, reference.trim_start_matches('#')) { + collect_external_resources(base, referenced, collected, seen)?; + } + continue; + } + let resolved = if base.has_fragment() { let mut base_without_fragment = base.clone(); base_without_fragment.set_fragment(None);