Skip to content

Commit 2860830

Browse files
tejodorusbrettz9
andauthored
- Fix: Avoid cache corruption when the returned structure is modified.
- Fix: Avoid cache corruption when the returned structure is modified. Fixes #102. (@tejodorus) Co-authored-by: Brett Zamir <[email protected]>
1 parent 61c654f commit 2860830

11 files changed

+25
-10
lines changed

badges/tests-badge.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index-browser-esm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ JSONPath.toPathArray = function (expr) {
982982
return !match || !match[1] ? exp : subx[match[1]];
983983
});
984984
cache[expr] = exprList;
985-
return cache[expr];
985+
return cache[expr].concat();
986986
};
987987

988988
/**

dist/index-browser-esm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-browser-esm.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-browser-umd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@
988988
return !match || !match[1] ? exp : subx[match[1]];
989989
});
990990
cache[expr] = exprList;
991-
return cache[expr];
991+
return cache[expr].concat();
992992
};
993993

994994
/**

dist/index-browser-umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-browser-umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-node-cjs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ JSONPath.toPathArray = function (expr) {
729729
return !match || !match[1] ? exp : subx[match[1]];
730730
});
731731
cache[expr] = exprList;
732-
return cache[expr];
732+
return cache[expr].concat();
733733
};
734734

735735
JSONPath.prototype.vm = vm__default['default'];

dist/index-node-esm.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ JSONPath.toPathArray = function (expr) {
721721
return !match || !match[1] ? exp : subx[match[1]];
722722
});
723723
cache[expr] = exprList;
724-
return cache[expr];
724+
return cache[expr].concat();
725725
};
726726

727727
JSONPath.prototype.vm = vm;

src/jsonpath.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ JSONPath.toPathArray = function (expr) {
699699
return !match || !match[1] ? exp : subx[match[1]];
700700
});
701701
cache[expr] = exprList;
702-
return cache[expr];
702+
return cache[expr].concat();
703703
};
704704

705705
export {JSONPath};

0 commit comments

Comments
 (0)