Skip to content

Commit

Permalink
- Fix: Handle React-Native environment's lack of support for
Browse files Browse the repository at this point in the history
    Node vm (@simon-scherzinger); closes JSONPath-Plus#87
- Testing: Avoid favicon check
- npm: Bump to 0.18.0
  • Loading branch information
brettz9 committed Oct 20, 2018
1 parent f58d9f7 commit a52dd41
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# jsonpath-plus changes

## ?
## 0.18.0 (October 20, 2018)

- Security enhancement: Use global eval instead of regular eval
- Fix: Handle React-Native environment's lack of support for
Node vm (@simon-scherzinger); closes #87
- Refactoring: Use arrow functions, for-of, declare block scope vars
closer to block
- Docs: Clarify current `wrap` behavior
Expand Down
3 changes: 2 additions & 1 deletion dist/index-es.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function _possibleConstructorReturn(self, call) {

/* eslint-disable no-eval */
var globalEval = eval;
var supportsNodeVM = typeof module !== 'undefined' && !!module.exports && !(typeof navigator !== 'undefined' && navigator.product === 'ReactNative');
var allowedResultTypes = ['value', 'path', 'pointer', 'parent', 'parentProperty', 'all'];
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
Expand All @@ -158,7 +159,7 @@ var moveToAnotherArray = function moveToAnotherArray(source, target, conditionCb
}
};

var vm = typeof module !== 'undefined' ? require('vm') : {
var vm = supportsNodeVM ? require('vm') : {
/**
* @param {string} expr Expression to evaluate
* @param {object} context Object whose items will be added to evaluation
Expand Down
2 changes: 1 addition & 1 deletion dist/index-es.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index-es.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/index-umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@

/* eslint-disable no-eval */
var globalEval = eval;
var supportsNodeVM = typeof module !== 'undefined' && !!module.exports && !(typeof navigator !== 'undefined' && navigator.product === 'ReactNative');
var allowedResultTypes = ['value', 'path', 'pointer', 'parent', 'parentProperty', 'all'];
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
Expand All @@ -164,7 +165,7 @@
}
};

var vm = typeof module !== 'undefined' ? require('vm') : {
var vm = supportsNodeVM ? require('vm') : {
/**
* @param {string} expr Expression to evaluate
* @param {object} context Object whose items will be added to evaluation
Expand Down
2 changes: 1 addition & 1 deletion dist/index-umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index-umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Stefan Goessner",
"name": "jsonpath-plus",
"version": "0.17.0",
"version": "0.18.0",
"main": "dist/index-umd.js",
"module": "dist/index-es.js",
"description": "A JS implementation of JSONPath with some additional operators",
Expand Down Expand Up @@ -41,6 +41,9 @@
"engines": {
"node": ">=6.0"
},
"react-native": {
"vm": false
},
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.1.2",
Expand Down
4 changes: 3 additions & 1 deletion src/jsonpath.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable no-eval */

const globalEval = eval;
const supportsNodeVM = typeof module !== 'undefined' && !!module.exports &&
!(typeof navigator !== 'undefined' && navigator.product === 'ReactNative');
const allowedResultTypes = ['value', 'path', 'pointer', 'parent', 'parentProperty', 'all'];
const {hasOwnProperty} = Object.prototype;

Expand All @@ -22,7 +24,7 @@ const moveToAnotherArray = function (source, target, conditionCb) {
}
};

const vm = typeof module !== 'undefined'
const vm = supportsNodeVM
? require('vm') : {
/**
* @param {string} expr Expression to evaluate
Expand Down
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>JSONPath Tests</title>
<link rel="stylesheet" href="../node_modules/nodeunit/share/nodeunit.css" type="text/css" />
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
<script src="../node_modules/nodeunit/examples/browser/nodeunit.js"></script>
<script type="module" src="../test-helpers/testLoading.js"></script>
<script defer="defer" src="../test-helpers/loadTests.js"></script>
Expand Down

0 comments on commit a52dd41

Please sign in to comment.