Skip to content

Conversation

@jonluca
Copy link
Collaborator

@jonluca jonluca commented Nov 11, 2025

This changes the URL parsing behavior to actually respect RFC 6901. Previously we were URL encoding too often. This will be considered a breaking change, as it will change how previously parsed documents are bundled and dereferenced.

This also adds a new mergeKey option.

Additionally, the new output will be ESM.

Should fix #383, #356, and makes progress on #370

BREAKING CHANGE: Change URL encoding to use strict RFC 6901, add new mergeKeys dereference option

BREAKING CHANGE: Change default merge keys option and add merge keys strategy, bump dependencies
Copilot AI review requested due to automatic review settings November 11, 2025 18:28
Copilot finished reviewing on behalf of jonluca November 11, 2025 18:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements RFC 6901-compliant JSON pointer handling, migrates to ESM output, and adds a new mergeKeys dereference option. The changes address URL encoding issues that caused characters like $ in JSON pointers to be unnecessarily encoded, breaking references to JSON Schema $defs.

Key changes:

  • Remove unnecessary encodeURIComponent/decodeURIComponent calls in JSON pointer parsing and construction, keeping only RFC 6901-required encoding (~~0, /~1)
  • Update tsconfig.json to output ESM modules (NodeNext, node16 module resolution)
  • Add mergeKeys option to control key merging during dereferencing (defaults to true)

Reviewed Changes

Copilot reviewed 28 out of 31 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/util/url.ts Removes URL decoding in safePointerToPath and adds hash decoding in resolve
lib/pointer.ts Removes URL encoding in Pointer.join and decoding in Pointer.parse per RFC 6901
lib/ref.ts Adds deepMerge logic and mergeKeys option support to control key collision handling
lib/options.ts Defines new mergeKeys option with default true
test/specs/bundle-defs-encoding/ New test suite verifying $defs references are not URL-encoded
tsconfig.json Updates to ESM output configuration
package.json Updates module type to "module" and dependency versions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jonluca jonluca merged commit fbb56b5 into main Nov 11, 2025
13 checks passed
@jonluca jonluca deleted the feat/fix-url-encoding branch November 11, 2025 18:35
@coveralls
Copy link

Pull Request Test Coverage Report for Build 19275102544

Details

  • 20 of 33 (60.61%) changed or added relevant lines in 5 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-6.0%) to 83.127%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/ref.ts 5 18 27.78%
Files with Coverage Reduction New Missed Lines %
lib/util/next.ts 1 41.67%
lib/util/url.ts 1 63.97%
Totals Coverage Status
Change from base Build 17625174086: -6.0%
Covered Lines: 949
Relevant Lines: 1069

💛 - Coveralls

@github-actions
Copy link

🎉 This PR is included in version 15.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants