Skip to content

Commit 202cb89

Browse files
gkelloggdavidlehn
authored andcommitted
Don't use terms with expanded definitions as prefixes in 1.0 mode.
1 parent 87d27cd commit 202cb89

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
`@base` or document base.
1515
- Better checking of absolute IRIs.
1616
- Terms that beging with a ':' are not considered absolute or compact IRIs.
17+
- Don't use terms with `@prefix`: false, or expanded term definitions to construct compact IRIs.
1718

1819
### Removed
1920
- **BREAKING**: Remove callback API support. This includes removing support

lib/context.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ api.createTermDefinition = (
445445
}
446446
mapping['@id'] = id;
447447
// indicate if this term may be used as a compact IRI prefix
448-
mapping._prefix = (!mapping._termHasColon &&
449-
id.match(/[:\/\?#\[\]@]$/) &&
450-
(simpleTerm || api.processingMode(activeCtx, 1.0)));
448+
mapping._prefix = (simpleTerm &&
449+
!mapping._termHasColon &&
450+
id.match(/[:\/\?#\[\]@]$/));
451451
}
452452
}
453453

@@ -770,8 +770,8 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
770770
}
771771

772772
// use mapping if prefix is defined
773-
if(activeCtx.mappings.has(prefix)) {
774-
const mapping = activeCtx.mappings.get(prefix);
773+
const mapping = activeCtx.mappings.get(prefix);
774+
if(mapping && mapping._prefix) {
775775
return mapping['@id'] + suffix;
776776
}
777777

tests/test-common.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ const TEST_TYPES = {
3232
specVersion: ['json-ld-1.0'],
3333
// FIXME
3434
idRegex: [
35-
// terms
36-
/compact-manifest.jsonld#tp001$/,
3735
// type set
3836
/compact-manifest.jsonld#t0104$/,
3937
/compact-manifest.jsonld#t0105$/,
@@ -163,8 +161,6 @@ const TEST_TYPES = {
163161
/expand-manifest.jsonld#te049$/,
164162
// invalid keyword alias
165163
/expand-manifest.jsonld#te051$/,
166-
// IRI prefixes
167-
/expand-manifest.jsonld#tpr29$/,
168164
// protected null IRI mapping
169165
/expand-manifest.jsonld#tpr28$/,
170166
// remote

0 commit comments

Comments
 (0)