diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-08-22 20:52:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-22 20:52:03 -0700 |
commit | 53ccbaf4f50d6876e1f4d44acdac2268b3d75233 (patch) | |
tree | 80b8037a85bf3d46e7a64782aa0539ee04be3a46 /web/src/js/utils.js | |
parent | 62ab2f2fd5188f31e99560dce788ba85c2933a1a (diff) | |
parent | eddc4243791c2c2b1a91c1d8ae49b830206bc6df (diff) | |
download | mitmproxy-53ccbaf4f50d6876e1f4d44acdac2268b3d75233.tar.gz mitmproxy-53ccbaf4f50d6876e1f4d44acdac2268b3d75233.tar.bz2 mitmproxy-53ccbaf4f50d6876e1f4d44acdac2268b3d75233.zip |
Merge pull request #1489 from mitmproxy/web_refactor
Web refactor
Diffstat (limited to 'web/src/js/utils.js')
-rw-r--r-- | web/src/js/utils.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/web/src/js/utils.js b/web/src/js/utils.js index e44182d0..e8470cec 100644 --- a/web/src/js/utils.js +++ b/web/src/js/utils.js @@ -107,14 +107,15 @@ fetchApi.put = (url, json, options) => fetchApi( ...options } ) - +// deep comparison of two json objects (dicts). arrays are handeled as a single value. +// return: json object including only the changed keys value pairs. export function getDiff(obj1, obj2) { let result = {...obj2}; for(let key in obj1) { if(_.isEqual(obj2[key], obj1[key])) result[key] = undefined - else if(!(Array.isArray(obj2[key]) && Array.isArray(obj1[key])) && - typeof obj2[key] == 'object' && typeof obj1[key] == 'object') + else if(Object.prototype.toString.call(obj2[key]) === '[object Object]' && + Object.prototype.toString.call(obj1[key]) === '[object Object]' ) result[key] = getDiff(obj1[key], obj2[key]) } return result |