Skip to content

Commit 87d27cd

Browse files
gkelloggdavidlehn
authored andcommitted
@vocab can be a compact IRI.
1 parent a09e492 commit 87d27cd

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
### Changed
1111
- Default processing mode changed to json-ld-1.1. Allows a 1.1 context to be
1212
used after non-1.1 contexts.
13-
- `@vocab` can be relative in 1.0, resolved against either a previous `@vocab`,
13+
- `@vocab` can be relative or a Compact IRI in 1.1, resolved against either a previous `@vocab`,
1414
`@base` or document base.
1515
- Better checking of absolute IRIs.
1616
- Terms that beging with a ':' are not considered absolute or compact IRIs.

lib/context.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,14 @@ api.process = async ({
227227
'Invalid JSON-LD syntax; the value of "@vocab" in a ' +
228228
'@context must be a string or null.',
229229
'jsonld.SyntaxError', {code: 'invalid vocab mapping', context: ctx});
230-
} else if(!_isAbsoluteIri(value)) {
231-
if(api.processingMode(rval, 1.0)) {
232-
throw new JsonLdError(
233-
'Invalid JSON-LD syntax; the value of "@vocab" in a ' +
234-
'@context must be an absolute IRI.',
235-
'jsonld.SyntaxError', {code: 'invalid vocab mapping', context: ctx});
236-
}
230+
} else if(!_isAbsoluteIri(value) && api.processingMode(rval, 1.0)) {
231+
throw new JsonLdError(
232+
'Invalid JSON-LD syntax; the value of "@vocab" in a ' +
233+
'@context must be an absolute IRI.',
234+
'jsonld.SyntaxError', {code: 'invalid vocab mapping', context: ctx});
235+
} else {
237236
rval['@vocab'] = _expandIri(rval, value, {vocab: true, base: true},
238237
undefined, undefined, options);
239-
} else {
240-
rval['@vocab'] = value;
241238
}
242239
defined.set('@vocab', true);
243240
}

tests/test-common.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ const TEST_TYPES = {
197197
/expand-manifest.jsonld#tso11$/,
198198
// colliding keywords
199199
/expand-manifest.jsonld#t0114$/,
200-
// vocab iri/term
201-
/expand-manifest.jsonld#te046$/,
202-
/expand-manifest.jsonld#te047$/,
203200
// included
204201
/expand-manifest.jsonld#tin01$/,
205202
/expand-manifest.jsonld#tin02$/,

0 commit comments

Comments
 (0)