Skip to content

Commit 9a042a6

Browse files
committed
0.25.0
1 parent b7a8e4e commit 9a042a6

File tree

4 files changed

+28
-60
lines changed

4 files changed

+28
-60
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# v0.25.0
2+
## Changed
3+
* Update dependencies
4+
5+
## Added
6+
* Add AuditProcessor
7+
18
# v0.24.0
29
## Changed
310
* template: provide more useful error message on duplicate keys during template rendering

lib/template.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const Mustache = require('mustache');
2424
const yaml = require('js-yaml');
2525
const $RefParser = require('@apidevtools/json-schema-ref-parser');
2626
const deepmerge = require('deepmerge');
27-
const JSONPath = require('jsonpath-plus').JSONPath;
2827
const axios = require('axios');
2928
const mexp = require('math-expression-evaluator');
3029

@@ -1242,6 +1241,20 @@ class Template {
12421241
return rendered;
12431242
}
12441243

1244+
JsonPathMinus(path, obj) {
1245+
// Only supports dot/bracket notation, e.g. "foo.bar[0].baz"
1246+
const parts = path
1247+
.replace(/\[(\w+)\]/g, '.$1') // convert [0] to .0
1248+
.split('.')
1249+
.filter(Boolean);
1250+
let result = obj;
1251+
for (const part of parts) {
1252+
if (result == null) return [];
1253+
result = result[part];
1254+
}
1255+
return [result];
1256+
}
1257+
12451258
/**
12461259
* Fetch data using an HTTP request for properties that specify a URL
12471260
*
@@ -1273,7 +1286,8 @@ class Template {
12731286
view[def] = res.data;
12741287
}
12751288
if (defProp.pathQuery) {
1276-
const results = JSONPath(defProp.pathQuery, view[def]);
1289+
// const results = JSONPath(defProp.pathQuery, view[def]);
1290+
const results = JsonPathMinus(defProp.pathQuery, view[def]);
12771291
view[def] = results[0];
12781292
}
12791293
return Promise.resolve();

package-lock.json

Lines changed: 4 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@
5050
"@f5devcentral/atg-storage": "^1.3.9",
5151
"adm-zip": "^0.5.10",
5252
"ajv": "^6.12.6",
53-
"axios": "^0.30.0",
53+
"axios": "^0.30.2",
5454
"deepmerge": "^4.3.1",
5555
"js-yaml": "^4.1.0",
56-
"jsonpath-plus": "^10.2.0",
5756
"math-expression-evaluator": "^1.4.0",
5857
"merge-lite": "^1.0.2",
5958
"mustache": "^4.2.0",

0 commit comments

Comments
 (0)