You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The generated patches are similar (but not the same) to the RFC-6902 JSON patch standard, except that the path property is an array, rather than a string. This makes processing patches easier. If you want to normalize to the official specification, patch.path = patch.path.join("/") should do the trick.
The advice for making the patches RFC-6920 compliant is incorrect. The suggested adjustment, patch.path.join("/"), will never return a path string with a leading /.
RFC-6902 requires the path to be a JSON Pointer, defined in RFC-6901. The grammar in RFC-6901 §3 defines a json-pointer token as follows:
json-pointer = *( "/" reference-token )
Thus, the only json-pointer which does not start with / is the empty string.
The suggestion in the docs produces non-compliant paths such as a/b/c (instead of /a/b/c).
Link to repro
See next section.
To Reproduce
const path = ['a'];
console.log(path.join("/"));
Observed behavior
a
Expected behavior
/a
Obviously we don't expect join() to produce this, but rather we expect the docs to suggest code which would.
Environment
Any environment you want---this is how join() works.
Immer version:
I filed this report against the latest version of Immer
Occurs with setUseProxies(true)
Occurs with setUseProxies(false) (ES5 only)
The text was updated successfully, but these errors were encountered:
🐛 Bug Report
The patches documentation says
The advice for making the patches RFC-6920 compliant is incorrect. The suggested adjustment,
patch.path.join("/")
, will never return apath
string with a leading/
.RFC-6902 requires the path to be a JSON Pointer, defined in RFC-6901. The grammar in RFC-6901 §3 defines a
json-pointer
token as follows:Thus, the only
json-pointer
which does not start with/
is the empty string.The suggestion in the docs produces non-compliant paths such as
a/b/c
(instead of/a/b/c
).Link to repro
See next section.
To Reproduce
Observed behavior
Expected behavior
Obviously we don't expect
join()
to produce this, but rather we expect the docs to suggest code which would.Environment
Any environment you want---this is how
join()
works.setUseProxies(true)
setUseProxies(false)
(ES5 only)The text was updated successfully, but these errors were encountered: