Skip to content

Commit 28fe0ff

Browse files
committed
Fix resolving context null values.
1 parent 8230aaa commit 28fe0ff

File tree

6 files changed

+26
-0
lines changed

6 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Fixed
44
- More support for `"@type": "@none"`.
55
- JSON literal value handling issues (`null` and `[]`).
6+
- Fix resolving context `null` values.
67

78
## 2.0.1 - 2019-12-10
89

lib/ContextResolver.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ function _throwInvalidLocalContext(ctx) {
210210
* @param base the base IRI to use to resolve relative IRIs.
211211
*/
212212
function _resolveContextUrls({context, base}) {
213+
if(!context) {
214+
return;
215+
}
216+
213217
const ctx = context['@context'];
214218

215219
if(_isString(ctx)) {

tests/contexts/context-0008.jsonld

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": [
3+
{
4+
"t1": "ex:t1"
5+
},
6+
{
7+
"t1": null
8+
}
9+
]
10+
}

tests/manifest.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,11 @@
4848
"purpose": "RDF serialized in N-Quads may contain comments",
4949
"input": "fromRdf-0001-in.nq",
5050
"expect": "fromRdf-0001-out.jsonld"
51+
}, {
52+
"@id": "#t0008",
53+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
54+
"name": "resolve context null values",
55+
"input": "remote-0008-in.jsonld",
56+
"expect": "remote-0008-out.jsonld"
5157
}]
5258
}

tests/remote-0008-in.jsonld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"@context": "http://localhost:8000/context-0008.jsonld",
3+
"t1": "t1 should have been nulled out"
4+
}

tests/remote-0008-out.jsonld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

0 commit comments

Comments
 (0)