diff options
author | Clemens <cle1000.cb@gmail.com> | 2016-07-22 19:07:53 +0200 |
---|---|---|
committer | Clemens <cle1000.cb@gmail.com> | 2016-07-22 19:07:53 +0200 |
commit | f578bf512248c609296d2ff0ea2007a6feac561f (patch) | |
tree | 7c58f14f09df0699cc788cde84e60b76d5f863e3 /web/src/js/utils.js | |
parent | 70ca10b423de4a57a395798aa94189ba4da7840f (diff) | |
download | mitmproxy-f578bf512248c609296d2ff0ea2007a6feac561f.tar.gz mitmproxy-f578bf512248c609296d2ff0ea2007a6feac561f.tar.bz2 mitmproxy-f578bf512248c609296d2ff0ea2007a6feac561f.zip |
file upload updates contentview, editable contentloader, diffs on upload
Diffstat (limited to 'web/src/js/utils.js')
-rw-r--r-- | web/src/js/utils.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/web/src/js/utils.js b/web/src/js/utils.js index eceda195..ba07b00a 100644 --- a/web/src/js/utils.js +++ b/web/src/js/utils.js @@ -105,3 +105,17 @@ fetchApi.put = (url, json, options) => fetchApi( ...options } ) + + +export function getDiff(obj1, obj2) { + let result = {...obj2}; + _.forIn(obj1, (value, key) => { + if(_.isEqual(obj2[key], obj1[key])) + result[key] = undefined; + else if(typeof Array.isArray(obj2[key]) && Array.isArray(obj2[key])) + result[key] = {...obj2[key]}; + else if(typeof obj2[key] == 'object' && typeof obj1[key] == 'object') + result[key] = getDiff(obj1[key], obj2[key]); + }); + return result; +} |