Skip to content

Commit db15734

Browse files
authored
Fix @base not resolving in nested inner contexts
1 parent 5524a16 commit db15734

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/ContextParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,14 +617,14 @@ must be one of ${Util.CONTAINERS.join(', ')}`, ERROR_CODES.INVALID_CONTAINER_MAP
617617
parentContext[key] = {...parentContext[key]};
618618
delete parentContext[key]['@context'];
619619
await this.parse(value['@context'],
620-
{ ...options, parentContext, ignoreProtection: true, ignoreRemoteScopedContexts: true, ignoreScopedContexts: true });
620+
{ ...options, external: false, parentContext, ignoreProtection: true, ignoreRemoteScopedContexts: true, ignoreScopedContexts: true });
621621
} catch (e) {
622622
throw new ErrorCoded(e.message, ERROR_CODES.INVALID_SCOPED_CONTEXT);
623623
}
624624
}
625625

626626
value['@context'] = (await this.parse(value['@context'],
627-
{ ...options, minimalProcessing: true, ignoreRemoteScopedContexts: true, parentContext: context }))
627+
{ ...options, external: false, minimalProcessing: true, ignoreRemoteScopedContexts: true, parentContext: context }))
628628
.getContextRaw();
629629
}
630630
}

test/ContextParser-test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,8 @@ Tried mapping @id to {}`, ERROR_CODES.KEYWORD_REDEFINITION));
16881688
.resolves.toEqual(new JsonLdContextNormalized({
16891689
prop: {
16901690
'@context': {
1691+
"@__baseDocument": true,
1692+
"@base": "http://example.org/remote_cyclic_scoped_indirect_1.jsonld",
16911693
prop: {
16921694
'@context': 'http://example.org/remote_cyclic_scoped_indirect_1.jsonld',
16931695
'@id': 'ex:prop',
@@ -1927,6 +1929,8 @@ Tried mapping @id to {}`, ERROR_CODES.KEYWORD_REDEFINITION));
19271929
.resolves.toEqual(new JsonLdContextNormalized({
19281930
prop: {
19291931
'@context': {
1932+
"@__baseDocument": true,
1933+
"@base": "http://example.org/remote_cyclic_scoped_indirect_1.jsonld",
19301934
prop: {
19311935
'@context': 'http://example.org/remote_cyclic_scoped_indirect_1.jsonld',
19321936
'@id': 'ex:prop',

0 commit comments

Comments
 (0)