Patching string value does not work
kfrajtak opened this issue · comments
Hi,
I have run into an issue when a string value is not correctly patched.
The minimal code to reproduce it is here
var diffPatch = new JsonDiffPatchDotNet.JsonDiffPatch();
var left = JToken.Parse(@"{ ""value"": ""username=administrator&key=333&project_id=1""}");
var rigth = JToken.Parse(@"{ ""value"": ""username=administrator&key=582eb3a9b422d1925c96daa2d4f86f6c&project_id=1"" }");
var patch = diffPatch.Diff(left, right); // get the patch
var output = diffPatch.Patch(left, patch); // apply the patch
and the output (left
+ patch
, where patch
is the difference between left
and right
) is { "value": "key=582eb3a9b422d1925c96daa2d4f86f6c&pro" }
which is not the value of right
.
the patch
{
"value": [
"@@ -24,11 +24,40 @@\n key=\n-333\n+582eb3a9b422d1925c96daa2d4f86f6c\n &pro\n",
0,
2
]
}
Am I missing something? Is there a way how to turn off this patch mode for long(ish) strings?
PS: It works in the master branch, I am experiencing issues with package 1.0.5.0 and .NET 4.6.1.
<package id="JsonDiffPatch.Net" version="1.0.5.0" targetFramework="net461" />
Thanks,
Karel
Hi Karel,
Thank you for reporting this and apologies for the delayed response.
I tried running your test and it passed for me. Are you sure you are using the latest code? This is a bug that was fixed a couple of months ago. A quick workaround without syncing to the latest would be:
new JsonDiffPatch(new Options { TextDiff = TextDiffMode.Simple });
Thanks