Skip to content

Commit 3fcf484

Browse files
3.1.0
1 parent e729404 commit 3fcf484

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

dist/fast-json-patch.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! fast-json-patch, version: 3.0.0-1 */
1+
/*! fast-json-patch, version: 3.1.0 */
22
var jsonpatch =
33
/******/ (function(modules) { // webpackBootstrap
44
/******/ // The module cache
@@ -464,6 +464,9 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
464464
}
465465
while (true) {
466466
key = keys[t];
467+
if (key && key.indexOf('~') != -1) {
468+
key = helpers_js_1.unescapePathComponent(key);
469+
}
467470
if (banPrototypeModifications && key == '__proto__') {
468471
throw new TypeError('JSON-Patch: modifying `__proto__` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README');
469472
}
@@ -505,9 +508,6 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
505508
}
506509
}
507510
else {
508-
if (key && key.indexOf('~') != -1) {
509-
key = helpers_js_1.unescapePathComponent(key);
510-
}
511511
if (t >= len) {
512512
var returnValue = objOps[operation.op].call(operation, obj, key, document); // Apply patch
513513
if (returnValue.test === false) {
@@ -519,7 +519,7 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
519519
obj = obj[key];
520520
// If we have more keys in the path, but the next value isn't a non-null object,
521521
// throw an OPERATION_PATH_UNRESOLVABLE error instead of iterating again.
522-
if (t < len && (!obj || typeof obj !== "object")) {
522+
if (validateOperation && t < len && (!obj || typeof obj !== "object")) {
523523
throw new exports.JsonPatchError('Cannot perform operation at the desired path', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);
524524
}
525525
}
@@ -872,7 +872,7 @@ function _generate(mirror, obj, patches, path, invertible) {
872872
var oldVal = mirror[key];
873873
if (helpers_js_1.hasOwnProperty(obj, key) && !(obj[key] === undefined && oldVal !== undefined && Array.isArray(obj) === false)) {
874874
var newVal = obj[key];
875-
if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null) {
875+
if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {
876876
_generate(oldVal, newVal, patches, path + "/" + helpers_js_1.escapePathComponent(key), invertible);
877877
}
878878
else {

0 commit comments

Comments
 (0)