aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/utils.js
diff options
context:
space:
mode:
authorClemens <cle1000.cb@gmail.com>2016-07-25 17:33:36 +0200
committerClemens <cle1000.cb@gmail.com>2016-07-25 17:33:36 +0200
commit68e437a740a1e3d7356c4f637337aba471ec222f (patch)
tree01ca75835ac38c6da4f38bebbf8e582fce72c487 /web/src/js/utils.js
parent1ea094e9dcf187a409dab9ca9a2b3a0b10f243f7 (diff)
downloadmitmproxy-68e437a740a1e3d7356c4f637337aba471ec222f.tar.gz
mitmproxy-68e437a740a1e3d7356c4f637337aba471ec222f.tar.bz2
mitmproxy-68e437a740a1e3d7356c4f637337aba471ec222f.zip
rewrite getDiff
Diffstat (limited to 'web/src/js/utils.js')
-rw-r--r--web/src/js/utils.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/web/src/js/utils.js b/web/src/js/utils.js
index ba07b00a..d3b99bd0 100644
--- a/web/src/js/utils.js
+++ b/web/src/js/utils.js
@@ -109,13 +109,12 @@ fetchApi.put = (url, json, options) => fetchApi(
export function getDiff(obj1, obj2) {
let result = {...obj2};
- _.forIn(obj1, (value, key) => {
- if(_.isEqual(obj2[key], obj1[key]))
+ for(let key in obj1) {
+ 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')
+ else if(!(Array.isArray(obj2[key]) && Array.isArray(obj1[key])) &&
+ typeof obj2[key] == 'object' && typeof obj1[key] == 'object')
result[key] = getDiff(obj1[key], obj2[key]);
- });
+ }
return result;
}