Skip to content

fix(core): only drop whole keyword segments in toDataPathSegments - #2675

Merged
lucas-koehler merged 3 commits into
eclipsesource:masterfrom
trackoor:fix/to-data-path-keyword-segments
Nov 25, 2026
Merged

lucas-koehler merged 3 commits into
eclipsesource:masterfrom
trackoor:fix/to-data-path-keyword-segments

Conversation

@trackoor

@trackoor trackoor commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2664.

toDataPathSegments removed anyOf/N/, allOf/N/, oneOf/N/ and then//else/ with regexes over the whole scope string, so they also matched inside property names (something_else became something_properties) and removed properties that are literally named then or else.

It now splits the scope into segments first and walks them: a combinator keyword followed by an index and a then/else segment are skipped where a keyword is expected, and the segment after properties is always taken as the property name.

One output changes: a scope that ends in a combinator index. #/properties/a/anyOf/0 used to give a.0 and now gives a (same for oneOf and allOf). anyOf/N doesn't add a data level, so a is the correct data path; the old result only came from the regex requiring a trailing slash. Other existing paths give the same output as before.

The PR also fixes decode: .replace(/~0/, '~') had no g flag, so only the first ~0 in a segment was decoded (a~0b~0c gave a~b~0c). ~1 already used the g flag.

Tests added to packages/core/test/util/path.test.ts:

  • property names ending in then/else, and properties named then, else and anyOf
  • scopes ending in anyOf/N, oneOf/N and allOf/N
  • decode and toDataPath with repeated ~0 and ~1 escapes in one segment

The full core suite (450 tests, plus 1 known failure) and eslint . in packages/core pass.

I used an AI coding assistant to help write this; I reviewed the change and ran the tests.

The anyOf/allOf/oneOf and then/else regexes matched inside property
names (something_else, strengthen) and also removed properties literally
named then or else. Walk the pointer segment by segment instead and only
skip keywords where a keyword is expected.

Fixes eclipsesource#2664
@CLAassistant

CLAassistant commented Nov 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@netlify

netlify Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 50b8dfb
🔍 Latest deploy log https://app.netlify.com/projects/jsonforms-examples/deploys/6b0609811b961c1065bb005e
😎 Deploy Preview https://deploy-preview-2675--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coveralls

coveralls commented Nov 23, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 84.905% — trackoor:fix/to-data-path-keyword-segments into eclipsesource:master. No base build found for eclipsesource:master.

@lucas-koehler lucas-koehler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @trackoor , thank you for the contribution ❤️
The PR already looks pretty good to me. I have two comments inline (one of them being optional). Please have a look.

Comment thread packages/core/src/util/path.ts Resolved
Comment thread packages/core/src/util/path.ts Resolved
@trackoor

Copy link
Copy Markdown
Contributor Author

Thanks for catching both! You're right about anyOf/0: I've updated the description to call out that change and added tests for trailing anyOf/oneOf/allOf indices. I also added the g flag to the ~0 replace in decode, with tests for a~0b~0c and the ~1 case (that one already had the flag).

@lucas-koehler lucas-koehler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM now 🚀 Thanks for the updates and the contribution ❤️

@lucas-koehler
lucas-koehler merged commit fe789f4 into eclipsesource:master Nov 25, 2026
8 checks passed
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.

Scope through a property whose name ends in "then" or "else" binds the control to the wrong data path

4 participants