Skip to content

Commit 416a390

Browse files
committed
fix: do not include symbols in js-travers
This commit sets `includeSymbols` to false, resulting in not throwing when calling RegExp.exec on them. Closes #180 Signed-off-by: Martin Pražák <martin.prazak@lutherone.com>
1 parent c8523a6 commit 416a390

File tree

5 files changed

+270
-190
lines changed

5 files changed

+270
-190
lines changed

lib/experimental/json-schema-discovery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exports.discoverModelDefinitions = discoverModelDefinitions;
1818
function discoverModelDefinitions(json, options) {
1919
const schemas = [];
2020
const stack = [];
21-
const result = traverse(json).forEach(function(item) {
21+
const result = traverse(json, {includeSymbols: false}).forEach(function(item) {
2222
let type = typeof item;
2323

2424
if (Array.isArray(item)) {

lib/template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ JsonTemplate.prototype.compile = function() {
4040
return this.schema;
4141
}
4242
const schema = {};
43-
traverse(this.template).reduce(function(schema, item) {
43+
traverse(this.template, {includeSymbols: false}).reduce(function(schema, item) {
4444
const key = this.key;
4545
const root = this.path[0];
4646
let match = null;
@@ -118,7 +118,7 @@ JsonTemplate.prototype.build = function(parameters) {
118118
this.compile();
119119

120120
function transform(obj) {
121-
return traverse(obj).map(function(item) {
121+
return traverse(obj, {includeSymbols: false}).map(function(item) {
122122
const ctx = this;
123123
const templates = /\{(([\!\^]?[a-zA-Z\$_][\w\$]*)\s*(=([^:\{\}]+))?(:(\w+))?)\}/g;
124124
function build(item) {

package-lock.json

Lines changed: 42 additions & 0 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"@commitlint/config-conventional": "^19.0.0",
33+
"agentkeepalive": "^4.6.0",
3334
"bluebird": "^3.3.4",
3435
"body-parser": "^2.0.0",
3536
"eslint": "^8.27.0",

0 commit comments

Comments
 (0)