Closed acidduckling closed 4 years ago
Hello,
I believe I have found a bug when generating the path for an object that has a tilde (~) in an object property. An index seems to be appended to the tilde in the path string for some reason.
Here is a small snippet which produces the issue:
const obj1 = { 'my~id': { name: 'value1' } }; const obj2 = { 'my~id': { name: 'value1 - renamed' } }; const patch = jsonPatch.compare(obj1, obj2); console.log(patch);
The actual output is: "[{"op":"replace","path":"/my~0id/name","value":"value1 - renamed"}]"
"[{"op":"replace","path":"/my~0id/name","value":"value1 - renamed"}]"
The expected output would be: "[{"op":"replace","path":"/my~id/name","value":"value1 - renamed"}]"
"[{"op":"replace","path":"/my~id/name","value":"value1 - renamed"}]"
EDIT: I can reproduce this problem in Chrome (78.0.3904.108), and running directly in Node 10.16
Cheers, Clay.
I've just realised that the tilde is part of the RFC for JSON Patch:
https://tools.ietf.org/html/rfc6902#appendix-A.14
So it looks like this is expected behaviour! I will just close this ticket.
Hello,
I believe I have found a bug when generating the path for an object that has a tilde (~) in an object property. An index seems to be appended to the tilde in the path string for some reason.
Here is a small snippet which produces the issue:
The actual output is:
"[{"op":"replace","path":"/my~0id/name","value":"value1 - renamed"}]"
The expected output would be:
"[{"op":"replace","path":"/my~id/name","value":"value1 - renamed"}]"
EDIT: I can reproduce this problem in Chrome (78.0.3904.108), and running directly in Node 10.16
Cheers, Clay.