Skip to content

Resolve percent-encoded fragments in JSON reference links - #370

Open
RKS (rksharma-owg) wants to merge 1 commit into
microsoft:mainfrom
rksharma-owg:codex/fix-percent-encoded-reference-links
Open

RKS (rksharma-owg) wants to merge 1 commit into
microsoft:mainfrom
rksharma-owg:codex/fix-percent-encoded-reference-links

Conversation

@rksharma-owg

Copy link
Copy Markdown

Document links for references such as #/$defs/foo%3Abar do not reach the foo:bar definition, even though current schema validation resolves it correctly. Link resolution matches the encoded text directly against property and anchor names.

Decode the URI fragment once before resolving JSON Pointer tokens or anchors. Keep the URI before # unchanged, including when the reference targets an embedded schema. Preserve the existing literal interpretation of malformed percent escapes so malformed input does not throw or break existing links.

Tests:

  • Nine new regression tests fail before the fix; the malformed-input compatibility control already passes. All ten pass afterward.
  • Cover colon/space/Unicode decoding, tilde and slash escapes, encoded separators, single decoding, anchors, embedded schemas and malformed input. Assertions verify the target location and reference range.
  • npm test on Node 22.23.1 passes compilation, 5,356 tests and nine lint checks; untouched upstream passed 5,346 tests and nine lint checks.
  • git diff --check passes.

No public API or dependency changes. This fixes document-link navigation; it does not change schema-validation behavior. Fragment handling follows the URI representation of JSON Pointer described in RFC 6901 section 6.

Related to #281.

Prepared with Codex assistance; the validation above ran locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant