Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace incorrectly adds value when target location does not exist #269

Open
rybesh opened this issue Feb 18, 2021 · 0 comments
Open

replace incorrectly adds value when target location does not exist #269

rybesh opened this issue Feb 18, 2021 · 0 comments

Comments

@rybesh
Copy link

rybesh commented Feb 18, 2021

Section 4.3 of RFC6902 says:

The target location MUST exist for the operation to be successful.

But fast-json-patch incorrectly does an add instead of failing in this situation:

var fastJsonPatch = require("fast-json-patch")
var document = { foo: "bar" };
var patch = [
  { op: "replace", path: "/biz", value: "baz" },
];
document = fastJsonPatch.applyPatch(document, patch).newDocument;

The result is:

{biz: "baz", foo: "bar"}
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

No branches or pull requests

1 participant