Skip to content

Commit

Permalink
Merge branch 'fix-83' of https://github.com/mweathers/JSON-Patch into…
Browse files Browse the repository at this point in the history
… 'master'

# Conflicts:
#	test/spec/duplexSpec.js

/issues/83
/pull/131
  • Loading branch information
tomalec committed Nov 21, 2016
2 parents 9850ef8 + a471f21 commit 4b59837
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/json-patch-duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ var jsonpatch;
_generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
}
else {
if (oldVal != newVal) {
if (oldVal !== newVal) {
changed = true;
patches.push({ op: "replace", path: path + "/" + escapePathComponent(key), value: deepClone(newVal) });
}
Expand Down
2 changes: 1 addition & 1 deletion src/json-patch-duplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ module jsonpatch {
_generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
}
else {
if (oldVal != newVal) {
if (oldVal !== newVal) {
changed = true;
patches.push({op: "replace", path: path + "/" + escapePathComponent(key), value: deepClone(newVal)});
}
Expand Down
15 changes: 15 additions & 0 deletions test/spec/duplexSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,21 @@ describe("duplex", function() {

expect(jsonpatch.compare(objA, objB)).toReallyEqual([]);
})

it("should replace 0 with empty string", function () {
var objA = {
user: 0
};
var objB = {
user: ''
};

expect(jsonpatch.compare(objA, objB)).toReallyEqual([{
op: "replace",
path: "/user",
value: ''
}]);
});
});


Expand Down

0 comments on commit 4b59837

Please sign in to comment.