mongoose-diff-history icon indicating copy to clipboard operation
mongoose-diff-history copied to clipboard

Problem when saving URL in diff

Open flippyang opened this issue 5 years ago • 4 comments

I have this document where i saved the URL and sources in array of object. Here is an example of how my json look like:

{
"data":
[
  {
     "firstName":"John",
     "lastName":"Doe",
     "sources": [{
             "url": "https://www.successcds.net/learn-english/articles-definition-examples-types-exercises.html",
              "title":"URL example",
          },
          {
              "url": "https://websitebuilders.com/how-to/web-at-a-glance/url-examples/",
              "title":"URL example 2"
          }
]
} 

This is what happened in diff when I try to edit and save the url from https://websitebuilders.com/how-to/web-at-a-glance/url-examples/ to https://websitebuilders.com/how-to/web-at-a-glance/url-examples/#Example_1httpswebsitebuilderscom:

{
    "diff":{
          "sources": {"1": "url": ["@@-57,8+57,41@@xamples/+#Example_1httpswebsitebuilderscom", "0",  "2"]}
     }
} 

If you notice, the url are completely butchered. It seems like it combines both url (original and updated) into one encoded url. Somehow it happen to some of the url only especially the long one. Can you check please?

flippyang avatar Jun 19 '19 05:06 flippyang

Take a look at https://benjamine.github.io/jsondiffpatch/demo/ I think u are looking at the patch difference. For reverse applying it to get back the previous version

dhwpong avatar Jun 19 '19 10:06 dhwpong

@flippyang do you still have an issue?

zjr avatar Apr 24 '20 15:04 zjr

I don't have this issue.

ru4ert avatar Jul 24 '21 10:07 ru4ert

If you want to save without text diff. You need to path textDiff option to jsondiffpatch const diffPatcher = require('jsondiffpatch').create({ objectHash, textDiff:{minLength:1000} });

AlexandrMoroz avatar Oct 25 '21 14:10 AlexandrMoroz