mimani / mongoose-diff-history

Manage Mongo Collection diff History and versions
Apache License 2.0
55 stars 67 forks source link

Problem when saving URL in diff #43

Open flippyang opened 5 years ago

flippyang commented 5 years ago

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?

dhwpong commented 5 years ago

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

zjr commented 4 years ago

@flippyang do you still have an issue?

ru4ert commented 3 years ago

I don't have this issue.

AlexandrMoroz commented 3 years ago

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} });