Skip to content

Commit a37827c

Browse files
committed
Fix safe mode with @json value object.
1 parent 916d701 commit a37827c

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# jsonld ChangeLog
22

3+
## 8.1.1 - 2023-02-xx
4+
5+
### Fixed
6+
- Don't fail in safe mode for a value object with `"@type": "@json"`.
7+
38
## 8.1.0 - 2022-08-29
49

510
### Fixed

lib/expand.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ async function _expandObject({
614614
const ve = _expandIri(typeScopedContext, v,
615615
{base: true, vocab: true},
616616
{...options, typeExpansion: true});
617-
if(!_isAbsoluteIri(ve)) {
617+
if(ve !== '@json' && !_isAbsoluteIri(ve)) {
618618
if(options.eventHandler) {
619619
_handleEvent({
620620
event: {

tests/misc.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,48 @@ _:b0 <ex:p> "v" .
15071507
});
15081508
});
15091509

1510+
it('should have zero counts with @json value', async () => {
1511+
const input =
1512+
{
1513+
"ex:p": {
1514+
"@type": "@json",
1515+
"@value": [null]
1516+
}
1517+
}
1518+
;
1519+
const expected =
1520+
[
1521+
{
1522+
"ex:p": [
1523+
{
1524+
"@type": "@json",
1525+
"@value": [null]
1526+
}
1527+
]
1528+
}
1529+
]
1530+
;
1531+
const nq = `\
1532+
_:b0 <ex:p> "[null]"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON> .
1533+
`
1534+
;
1535+
1536+
await _test({
1537+
type: 'expand',
1538+
input,
1539+
expected,
1540+
eventCounts: {},
1541+
testSafe: true
1542+
});
1543+
await _test({
1544+
type: 'toRDF',
1545+
input,
1546+
expected: nq,
1547+
eventCodeLog: [],
1548+
testSafe: true
1549+
});
1550+
});
1551+
15101552
it('should count empty top-level object', async () => {
15111553
const input = {};
15121554
const expected = [];

0 commit comments

Comments
 (0)