Skip to content

Commit

Permalink
Check for constructor property
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbaileyuk committed Feb 29, 2024
1 parent c907b5e commit 335d38f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/jsonata.js
Expand Up @@ -1293,7 +1293,7 @@ var jsonata = (function() {
}
for(var ii = 0; ii < matches.length; ii++) {
var match = matches[ii];
if (match && match.isPrototypeOf(result)) {
if (match && (match.isPrototypeOf(result) || match instanceof Object.constructor)) {
throw {
code: "D1010",
stack: (new Error()).stack,
Expand Down
9 changes: 9 additions & 0 deletions test/implementation-tests.js
Expand Up @@ -974,6 +974,15 @@ describe("Tests that are specific to a Javascript runtime", () => {
code: "D1010",
});
});
it("should throw an error with constructor", async function() {
const expr = jsonata('{} ~> | constructor | {"is_admin": true} |');
expect(
expr.evaluate()
).to.eventually.be.rejected.to.deep.contain({
position: 7,
code: "D1010",
});
});
});
});

Expand Down

0 comments on commit 335d38f

Please sign in to comment.