Skip to content

Commit a575246

Browse files
committed
Fix term mapping of @reverse.
1 parent 3da84bd commit a575246

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Terms of the form of a relative IRI may not be used as prefixes.
1515
- Match spec error code "invalid context entry" vs "invalid context member".
1616
- Keywords may not be used as prefixes.
17+
- Term mapping of `@reverse`.
1718

1819
### Changed
1920
- Keep term definitions mapping to null so they may be protected.

lib/context.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,10 @@ api.createTermDefinition = ({
505505
'jsonld.SyntaxError', {code: 'invalid IRI mapping', context: localCtx});
506506
}
507507

508+
if(!api.isKeyword(reverse) && reverse.match(KEYWORD_PATTERN)) {
509+
return;
510+
}
511+
508512
// expand and add @id mapping
509513
const id = _expandIri(
510514
activeCtx, reverse, {vocab: true, base: false}, localCtx, defined,
@@ -516,18 +520,6 @@ api.createTermDefinition = ({
516520
'jsonld.SyntaxError', {code: 'invalid IRI mapping', context: localCtx});
517521
}
518522

519-
if(reverse.match(KEYWORD_PATTERN)) {
520-
// FIXME: remove logging and use a handler
521-
console.warn('WARNING: values beginning with "@" are reserved' +
522-
' for future use and ignored', {reverse});
523-
if(previousMapping) {
524-
activeCtx.mappings.set(term, previousMapping);
525-
} else {
526-
activeCtx.mappings.delete(term);
527-
}
528-
return;
529-
}
530-
531523
mapping['@id'] = id;
532524
mapping.reverse = true;
533525
} else if('@id' in value) {

0 commit comments

Comments
 (0)